PJ droopy pants Posted December 8, 2009 Share Posted December 8, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/184343-update-query-question/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 8, 2009 Share Posted December 8, 2009 http://us2.php.net/mysql_affected_rows Quote Link to comment https://forums.phpfreaks.com/topic/184343-update-query-question/#findComment-973206 Share on other sites More sharing options...
PJ droopy pants Posted December 8, 2009 Author Share Posted December 8, 2009 perfect thank you very much! Quote Link to comment https://forums.phpfreaks.com/topic/184343-update-query-question/#findComment-973210 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.