Jump to content

Update fields across multiple tables


WAMFT1
Go to solution Solved by cyberRobot,

Recommended Posts

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
Share on other sites

  • Solution

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.