I have this code, and what I am attempting to do is count rows in a table. What isn’t working, is if there aren’t any rows in the table, then it won’t return as “0”. How can I do that?
$getcomments = mysql_query("SELECT * FROM `comments` WHERE `blog_id` = '".$blog['id']."'");
while ($comments = mysql_fetch_assoc($getcomments))
{
if ($comments['blog_id'] == 0) {
$num_comments = "0";
} else {
$num_comments = mysql_num_rows($getcomments);
}
echo "<span class='comments'>$num_comments COMMENTS</span><br>";
}