Solved

Database

Posted on 2001-06-12
13
179 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Keep getting 503 on Curl request 6 31
.php tree directory? 5 56
Access Object's Property 9 22
PHP search array for either partial or complete values 3 5
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

920 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

15 Experts available now in Live!

Get 1:1 Help Now