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. Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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'; } } Quote Link to comment 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 } ?> Quote Link to comment 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.