ballhogjoni Posted August 13, 2007 Share Posted August 13, 2007 I want to check my db for a specific record, if it exists, exit else continue through the rest of the code. Can someone help me with this? My code is really too crappy to even post. I think I need to start from the beginning. Link to comment https://forums.phpfreaks.com/topic/64747-i-have-been-trying-to-do-this-forever/ Share on other sites More sharing options...
uwannadonkey Posted August 13, 2007 Share Posted August 13, 2007 post what you have, and we can help dont worry, i've seen WAY worse code than what u can come up with =D Link to comment https://forums.phpfreaks.com/topic/64747-i-have-been-trying-to-do-this-forever/#findComment-322904 Share on other sites More sharing options...
lemmin Posted August 13, 2007 Share Posted August 13, 2007 If you find it, call the die() function and everything will stop. Link to comment https://forums.phpfreaks.com/topic/64747-i-have-been-trying-to-do-this-forever/#findComment-322907 Share on other sites More sharing options...
ballhogjoni Posted August 13, 2007 Author Share Posted August 13, 2007 $result = mysql_query("SELECT * FROM products WHERE Username = '{$Username}'") or die(mysql_error()); while($productCheck = mysql_fetch_array($result)) { echo $productCheck['title']; if ($Username == $productCheck['Username'] && $productCheck['title'] == $title) {echo 'Hello';} else { echo'123'; } } Link to comment https://forums.phpfreaks.com/topic/64747-i-have-been-trying-to-do-this-forever/#findComment-322909 Share on other sites More sharing options...
hostfreak Posted August 13, 2007 Share Posted August 13, 2007 Pretty simple concept: <?php $Query = mysql_query("SELECT record FROM database") OR DIE(mysql_error()); $Returned_Rows = mysql_num_rows($Query); if ($Returned_Rows > 0) { exit("Exit Message"); } else { //Execute the script } ?> Link to comment https://forums.phpfreaks.com/topic/64747-i-have-been-trying-to-do-this-forever/#findComment-322910 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.