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
https://forums.phpfreaks.com/topic/184343-update-query-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.