Jump to content

Update query question


PJ droopy pants

Recommended Posts

I was wondering if it would be possible to stop further php and queries if an update did not happen (not just from error), example

$result = mysql_query("UPDATE `table1` SET `column1` = '0' WHERE  `id`='1'");
$result2 = mysql_query("UPDATE `table2` SET `column5` = '5' WHERE  `id`='1'");

How can i stop $result2 from running if in fact column1 on table1 was already 0? Of course I tried

$result = mysql_query("UPDATE `table1` SET `column1` = '0' WHERE `column1`!='0' AND  `id`='1'");
$result2 = mysql_query("UPDATE `table2` SET `column5` = '5' WHERE  `id`='1'");

However of course it would still run $result2.

I know that doing a select query before $result1 and checking would work but I was wondering if there was an easier way to append the $reslut1 update query to stop if no update happened.

Thanks for any help given  :D

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.