Solved

Database

Posted on 2001-06-12
13
178 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
  • 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article discusses four methods for overlaying images in a container on a web page
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now