fugix Posted April 22, 2011 Share Posted April 22, 2011 ok guys, im going out the door so forgive me for not showing any code..but I have a while loop whithin a while loop to display rows for two different id's. I have a mysql_num_rows vaiable set that displays 0 because there are 0 rows with the userid of 1...then it displays 2 because there are 2 rows with the userid of 3..now what i want to do is find a way to omit the return of 0 so that i can use the return of 2 alone. sorry if im not clear enough. Quote Link to comment https://forums.phpfreaks.com/topic/234483-while-loop-mysql_num_rows/ Share on other sites More sharing options...
fugix Posted April 22, 2011 Author Share Posted April 22, 2011 heres a snippet quick while($friend_query_array = mysql_fetch_assoc($friend_query)) { $friend_id = $friend_query_array['friend_id_array']; $query = mysql_query("SELECT * FROM events WHERE userid=$friend_id ORDER BY id DESC"); $queryrow = mysql_num_rows($query); if i echo $queryrow i get 02 for the two times that it checks the num rows Quote Link to comment https://forums.phpfreaks.com/topic/234483-while-loop-mysql_num_rows/#findComment-1205083 Share on other sites More sharing options...
Pikachu2000 Posted April 22, 2011 Share Posted April 22, 2011 If all you're trying to do is suppress the echo for an empty result set, only allow it if mysql_num_rows() > 0. echo mysql_num_rows($result_) > 0 ? 'At least one record returned' : ''; Quote Link to comment https://forums.phpfreaks.com/topic/234483-while-loop-mysql_num_rows/#findComment-1205086 Share on other sites More sharing options...
fugix Posted April 23, 2011 Author Share Posted April 23, 2011 thank you Quote Link to comment https://forums.phpfreaks.com/topic/234483-while-loop-mysql_num_rows/#findComment-1205122 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.