Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Database

Posted on 2001-06-12
13
Medium Priority
?
192 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
Technology Partners: 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

604 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