cenarius Posted July 25, 2009 Share Posted July 25, 2009 I wanna check if the value I am searching, exists in the database or not and then using if/else statement in PHP. This is the SQL code inside the php code. The selection is stored in variable $existing SELECT Player FROM Players WHERE Player='$player' $player is the value I am searching for (taken out of form). The php part which is bothering me: if ($existing == ?????) What to put in there? What is the result if no match is found? FALSE? NULL? MySql version: 5.0.81 Quote Link to comment https://forums.phpfreaks.com/topic/167406-solved-question-about-select/ Share on other sites More sharing options...
smerny Posted July 25, 2009 Share Posted July 25, 2009 $result = mysql_query("SELECT * FROM Players WHERE Player='".$player."'"); $num_rows = mysql_num_rows($result); if ($num_rows == 0) echo "this player does not exist in the database"; Quote Link to comment https://forums.phpfreaks.com/topic/167406-solved-question-about-select/#findComment-882751 Share on other sites More sharing options...
cenarius Posted July 26, 2009 Author Share Posted July 26, 2009 Thank you Quote Link to comment https://forums.phpfreaks.com/topic/167406-solved-question-about-select/#findComment-883113 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.