sjones Posted March 3, 2006 Share Posted March 3, 2006 Hello, I am trying to delete data from an administration modual. [a href=\"http://www.uswebproducts.com/country_savings/admin/csmag_admin.php?c=view_vendors\" target=\"_blank\"]You can view it here[/a]Below is the code I'm using. If someone can tell me where I went wrong, I would appreciate it.<table width="100%" cellpadding="0" cellspacing="0" border="0"><?php session_start(); include ('../connections/mysql_connect.php');//connect to database ?><tr> <td width="25%" valign="top"> <table> <tr> <td class="content_blank"><strong>Current Vendors</strong></td> </tr> <tr> <td><?php $vendor_query = "SELECT vendor_name FROM vendors"; $result = mysql_query($vendor_query); while (list($name) = mysql_fetch_row($result)) { echo "<span class='content'>$name<br></span>"; } ?> </td> </tr> </table> </td> <td width="75%" valign="top" class="form_left_side_border"> <table> <tr> <td class="content_blank"><strong>Remove a Vendor....</strong></td> </tr> <tr> <td class="content_blank"><?php if(empty($_POST['submit'])) { //If the submit button has not been set we will echo a welcome statement echo "<span class='content_blank'>Please select the name of the vendor to be removed.<BR></span>"; //end of the welcome message }else{ if(!empty($_POST['vendor_id'])) { $qry = mysql_query("DELETE * FROM vendors WHERE (vendor_id) = ('".$_POST['vendor_id']."');"); if($qry) { echo "<span class='content_blank'><strong>Vendor has been deleted</strong></span>"; } else { echo "<span class='content_blank'><strong>Error deleting vendor</strong></span>"; } } else { echo "<span class='content_blank'><strong>Error: You must select the Vendor Name!</strong></span>"; }}echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td> <br> <form method='post' action='csmag_admin.php?c=view_vendors'> <select name='cat_id'> <option>- Please select one -</option>\n"; $qry = mysql_query("SELECT * FROM vendors;"); while($rows = mysql_fetch_assoc($qry)) { echo "<option value='".$rows['vendor_id']."'>".$rows['vendor_name']."</option>\n"; }//#7 echo "</select> <input name='vendor_id' type='submit' value='Remove'> </form></td></tr></table>";?> </td> </tr> </table> </td></tr></table> Quote Link to comment Share on other sites More sharing options...
dcro2 Posted March 3, 2006 Share Posted March 3, 2006 Your SQL syntax for DELETE is wrong, the correct syntax is:[code]DELETE FROM table WHERE column = 'value';[/code] Quote Link to comment Share on other sites More sharing options...
sjones Posted March 3, 2006 Author Share Posted March 3, 2006 [!--quoteo(post=351427:date=Mar 3 2006, 04:05 PM:name=dcro2)--][div class=\'quotetop\']QUOTE(dcro2 @ Mar 3 2006, 04:05 PM) [snapback]351427[/snapback][/div][div class=\'quotemain\'][!--quotec--]Your SQL syntax for DELETE is wrong, the correct syntax is:[code]DELETE FROM table WHERE column = 'value';[/code][/quote] OK I have updated to this and it still does not work. Any Thoughts??$qry = mysql_query("DELETE FROM vendors WHERE (vendor_id) = ('".$_POST['vendor_id']."');"); Quote Link to comment Share on other sites More sharing options...
dcro2 Posted March 3, 2006 Share Posted March 3, 2006 Should be that you are checking for 'submit' to be empty, while your submit button's name is 'vendor_id':[code]if(empty($_POST['submit'])) { //If the submit button has not been set we will echo a welcome statement[/code][code]<input name='vendor_id' type='submit' value='Remove'>[/code]So.. it is [b]always[/b] trying to remove the vendor_id 'Remove'...It should be trying to remove $_POST['cat_id'] Quote Link to comment Share on other sites More sharing options...
sjones Posted March 3, 2006 Author Share Posted March 3, 2006 OK, I got it - again I can't thank you enough. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.