jwwceo Posted December 13, 2007 Share Posted December 13, 2007 I have a query which shows all the rows for certain conditions. I am using while($info = mysql_fetch_array( $data )) for my loop to output each row. I would like there to be a message saying "Nothing to edit" if the rows are empty. I tried this: if (empty ($info)){ echo "<p><h2>There are no packages to edit</h2></p>"; } But I get this message no matter what. I am thinking that $info has no value after the loop. What other variable can I use??? James Link to comment https://forums.phpfreaks.com/topic/81518-solved-empty-queries/ Share on other sites More sharing options...
Psycho Posted December 13, 2007 Share Posted December 13, 2007 You need to check the results. <?php if (mysql_num_rows($data)==0){ echo "<p><h2>There are no packages to edit</h2></p>"; } else ( while($info = mysql_fetch_array( $data )) //Do something } } ?> Link to comment https://forums.phpfreaks.com/topic/81518-solved-empty-queries/#findComment-413871 Share on other sites More sharing options...
jwwceo Posted December 13, 2007 Author Share Posted December 13, 2007 THANKS!!! Link to comment https://forums.phpfreaks.com/topic/81518-solved-empty-queries/#findComment-413882 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.