Solved

Database

Posted on 2001-06-12
13
186 Views
Last Modified: 2006-11-17
I need to be able to modify a database entry or delete a database entry...here is my code that i use...


<?
    mysql_connect("localhost", "us22667a", "pass");
    $query = "SELECT productname, price, productnum, description, pictureurl, productcat  FROM products";
    $result = mysql_db_query("db22667a", $query);

    if ($result) {
        while ($r = mysql_fetch_array($result)) {
            $productname = $r["productname"];
            $productnum = $r["productnum"];
     $price = $r["price"];
     echo '<a href=http://www.site.com/product.php?pid=' . $productnum . '>' . $productname . ' - ' . $price . '</a><br>';
        }
    } else {
        echo "No data.";
    }
    mysql_free_result($result);
?>
0
Comment
Question by:BrianGEFF719
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
  • +1
13 Comments
 
LVL 1

Expert Comment

by:Ludax
ID: 6180628
what is the problem ?
You want us to give you SQL or PHP ?? or both ???
0
 
LVL 8

Expert Comment

by:us111
ID: 6180709
details pls?
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6180720
i just need php code that will modify a database entry and another example to delete entry...I'm new to php.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:Ludax
ID: 6180723
this is not PHP but SQL

$query = "DELETE FROM tablename where yourfield=\"$yourvalue\"";

$test = mysql_db_query("db22667a", $query);

0
 
LVL 1

Expert Comment

by:Ludax
ID: 6180730
now the update

$query = "UPDATE tablename set youtfiel=\"$yourvalue\",your2ndfiel=\"your2ndvalue\" WHERE yourOtherOrSamefield=\"$yourothervalue\"";

$test = mysql_db_query("db22667a", $query);
0
 
LVL 19

Author Comment

by:BrianGEFF719
ID: 6181266
could you give me a example to update where the table name is CATS and there is CATNUM and CATTITLE and CATTITLE needs to be updated and CATNUM is send in the post...thanks
0
 
LVL 1

Expert Comment

by:Ludax
ID: 6181283
$query="UPDATE CATS set CATTITLE=\"$CATTITLE\" where CATNUM=\"$CATNUM\"";

$test=mysql_db_query("db22667a",$query);

this suppose that you pass CATNUM by posting $CATNUM and the new value of CATTITLE in $CATTITLE

;)
Ludax
0
 
LVL 8

Accepted Solution

by:
us111 earned 100 total points
ID: 6181301
<form action="update.php"    ....>
<input type="text" name="CATTITLE" value="fdffdffsdf">
<input type="hidden" name="CATNUM" value="10">
<input type="submit" name="submit" value="submit">
</form>

update.php:
<?
mysql_connect("localhost", "us22667a", "pass");
$query = "UPDATE CATS SET CATTITLE='$CATTITLE' WHERE CATNUM=$CATNUM";
$result = mysql_db_query("db22667a", $query);
?>
0
 
LVL 8

Expert Comment

by:us111
ID: 6181303
was editing
0
 
LVL 1

Expert Comment

by:Ludax
ID: 6181314
hehe I was faster...
0
 
LVL 8

Expert Comment

by:us111
ID: 6181337
although my mailbox is checked every minutes :))) but I'm not wainting for EE msg :))
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6419189
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with details.

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.

PLEASE DO NOT AWARD THE POINTS TO ME.

____________________________________________



Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.

Thank you everyone.

Moondancer :)
Community Support Moderator @ Experts Exchange

P.S.  REGARDING POINTS, Guidelines and more:  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp  
0
 
LVL 8

Expert Comment

by:us111
ID: 6698877
thx
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question