Jump to content

Recommended Posts

Hi ALL

Can anyone help me on this query please, all I'm trying to do is Update three tables in a same query.

 

 

if($_POST['submit']) {
	foreach($_POST as $job_id) { 
	mysql_query("UPDATE job_tb,blockbook,blockbook2 SET 
	job_tb.cust_address = 'Cancel' 
	blockbook.cust_address = 'Cancel'
	blockbook2.cust_address1 = 'Cancel'
		WHERE job_tb.job_id = '$job_id'
	AND blockbook.job_id = '$job_id' 
	AND blockbook2.job_id = '$job_id'"); 
	if (mysql_affected_rows() > 0) { // execute query 
    	print "<font color=red size=2> No. = $job_id has been Updated</font><p>"; 
  		} 
}
}

Thanks

Zed

Link to comment
https://forums.phpfreaks.com/topic/131132-problem-with-update/
Share on other sites

Thanks for replying but Where am I going wrong??? it no different than 2nd line so why error there and not in 2nd line?

 

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'blockbook.cust_address = 'Cancel' blockbook2.cust_address1 = 'Cancel' W' at line 3

 

 

Anyone any suggestions please.

 

Thanks

Zed

Link to comment
https://forums.phpfreaks.com/topic/131132-problem-with-update/#findComment-680995
Share on other sites

foreach($_POST as $job_id) {

 

isn't the best way of looping through the jobs, with that $_POST['submit'] is also goin to be queried - with or without success. How are you sending the 'job_ids' to the script?

 

Assuming there's a matching job id in each of the three tables it should work. It's either a problem with your logic or the inputs..

 

And I can't see enough code to say anything about the background colour problem..

 

Adam

Link to comment
https://forums.phpfreaks.com/topic/131132-problem-with-update/#findComment-681029
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.