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 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 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! Link to comment https://forums.phpfreaks.com/topic/184343-update-query-question/#findComment-973210 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.