Cronje Posted June 1, 2006 Share Posted June 1, 2006 I'm trying to determine the number of results from a SELECT, but am having trouble. My code:$query = mysql_query("SELECT * FROM tablename WHERE name='xxx'");$num = mysql_num_rows($query);It works fine when 'xxx' is in the table, but when it finds none, 'echo $num;' doesn't display anything.Help please!-Cronje Link to comment https://forums.phpfreaks.com/topic/10936-number-of-results-problem/ Share on other sites More sharing options...
samshel Posted June 1, 2006 Share Posted June 1, 2006 How about this ?$query = mysql_query("SELECT * FROM tablename WHERE name='xxx'");$num = (int)mysql_num_rows($query); Link to comment https://forums.phpfreaks.com/topic/10936-number-of-results-problem/#findComment-40833 Share on other sites More sharing options...
Cronje Posted June 1, 2006 Author Share Posted June 1, 2006 That worked perfectly. Thanks! Link to comment https://forums.phpfreaks.com/topic/10936-number-of-results-problem/#findComment-40839 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.