Jump to content


Photo

**solved** A simple query ?? - I hope


  • Please log in to reply
2 replies to this topic

#1 sjones

sjones
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 12 March 2006 - 05:09 PM

Can someone give me an idea of how to put a INSERT statement - with a WHERE clause. below is my blown example. I am calling the vendors from the database, allowing one of them to be selected, then hit an active or inactive radio button (active_id) I would like to upload the active_id to the vendors table where the $_POST['vendor_id'] = the vendor_id in the table. Any Thoughts ????

if(!empty($_POST['submit'])) {
$qry = mysql_query("INSERT INTO vendors (active_id) VALUES ('".$_POST['active_id']."') WHERE (vendor_id) = ('".$_POST['vendor_id']."');");
if($qry) { echo "<span class='content_blank'><strong>Vendor has been activated</strong></span>"; }
else { echo "<span class='content_blank'><strong>Error activating vendor</strong></span>"; }
}

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 12 March 2006 - 05:18 PM

You need to use an UPDATE statement, not an INSERT.

#3 sjones

sjones
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 12 March 2006 - 08:52 PM

Thank you that worked out fine.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users