Lamez Posted July 11, 2008 Share Posted July 11, 2008 On my homepage you can delete the entrys, but I want it to display a default message when you delete them all, in other words how can I tell if the database is empty? The database is structured like this: ID TITLE CONTENT and here is my whole code so far <?php $path = ""; $title = "Home"; $ban = "no"; $rank = "yes"; include ($path."main/include/cons/head.php"); $sql = mysql_query("SELECT * FROM `home` ORDER BY `id` DESC"); if($row['id'] < 1){ echo "nothing here"; } while($row = mysql_fetch_array($sql)){ echo "<p class=\"header\">".$row['title']; if($session->logged_in){ echo " <font size='2'><a href=".$path."main/include/dele_top.php?cmd=delete&id=".$row['id'].">Delete Topic(".$row['id'].")</a></font>"; } echo "</p><p class=\"maintext\">"; echo $row['content']; echo "</p>"; } include ($path."main/include/cons/foot.php"); ?> it displays nothing here, even when there is something there. Any Fixes? Quote Link to comment https://forums.phpfreaks.com/topic/114193-solved-database-empty/ Share on other sites More sharing options...
realjumper Posted July 11, 2008 Share Posted July 11, 2008 Surly.... $sql = mysql_query("SELECT * FROM `home` ORDER BY `id` DESC"); $num_rows = mysql_num_rows($sql); if($num_rows < '1'){ echo "nothing here"; } Quote Link to comment https://forums.phpfreaks.com/topic/114193-solved-database-empty/#findComment-587155 Share on other sites More sharing options...
Lamez Posted July 11, 2008 Author Share Posted July 11, 2008 lol I see my dumb mistake, there. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/114193-solved-database-empty/#findComment-587157 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.