WAMFT1 Posted February 13, 2015 Share Posted February 13, 2015 I am trying to setup so that I select a name from the dropdown menu (already works) then taking the ID number and using it to update multiple tables. I cannot get it to update anything. I don't really know what I am doing here, I thought based on other coding I have used that this would be simple. Please Help?? <? require('../edb.php'); $aid =$_REQUEST['aid']; if (isset($_POST['Submit'])) { $mysql_query1("UPDATE `adocs_ar_cert` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query2("UPDATE `adocs_cpd` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query3("UPDATE `adocs_fds` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query4("UPDATE `adocs_fsg_profile` SET Current='N' WHERE AdviserCode='$aid'"); $mysql_query5("UPDATE `adocs_sapl` SET Current='N' WHERE AdviserCode='$aid'"); }?> Link to comment https://forums.phpfreaks.com/topic/294575-update-fields-across-multiple-tables/ Share on other sites More sharing options...
cyberRobot Posted February 13, 2015 Share Posted February 13, 2015 You'll want to review the documentation for the mysql_query() function: http://php.net/manual/en/function.mysql-query.php Basically, your queries should look more like the following: mysql_query("UPDATE `adocs_ar_cert` SET Current='N' WHERE AdviserCode='$aid'"); Note that I removed the dollar sign and number from the call to mysql_query(). Also note that your queries are vulnerable to SQL injection attacks. Since it looks like $aid is a string, you want to escape the value with the following function: http://php.net/manual/en/function.mysql-real-escape-string.php Link to comment https://forums.phpfreaks.com/topic/294575-update-fields-across-multiple-tables/#findComment-1505610 Share on other sites More sharing options...
WAMFT1 Posted February 15, 2015 Author Share Posted February 15, 2015 Thanks cyberRobot The update now works, I have also added in the real escape string. Thanks for the links. Link to comment https://forums.phpfreaks.com/topic/294575-update-fields-across-multiple-tables/#findComment-1505760 Share on other sites More sharing options...
cyberRobot Posted February 17, 2015 Share Posted February 17, 2015 No problem, glad to help! Link to comment https://forums.phpfreaks.com/topic/294575-update-fields-across-multiple-tables/#findComment-1505900 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.