pneudralics Posted December 24, 2009 Share Posted December 24, 2009 I want to look for id 9. I know how to check the database with WHERE = '9', but what do I do to make it return true or false when it finds or not find 9? I pretty much want to check the database field id for a specific number. Not sure if the above is the way to go. I want php to tell me they found 9 or not. Link to comment https://forums.phpfreaks.com/topic/186241-how-can-i-get-php-to-return-true-or-false-when-it-checks-a-database-for-a-var/ Share on other sites More sharing options...
trq Posted December 24, 2009 Share Posted December 24, 2009 if ($result = mysql_query("SELECT id FROM tbl WHERE id = 9")) { if (mysql_num_rows($result)) { // found } else { // not found } } Link to comment https://forums.phpfreaks.com/topic/186241-how-can-i-get-php-to-return-true-or-false-when-it-checks-a-database-for-a-var/#findComment-983556 Share on other sites More sharing options...
pneudralics Posted December 24, 2009 Author Share Posted December 24, 2009 Thanks again. Link to comment https://forums.phpfreaks.com/topic/186241-how-can-i-get-php-to-return-true-or-false-when-it-checks-a-database-for-a-var/#findComment-983562 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.