?
Solved

Database

Posted on 2001-06-12
13
Medium Priority
?
190 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
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 
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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

764 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