ok, i writing a nwes script and want to find out how many comments there are on a particluar piece of news:
is me simple little function for this where $id is the number of the news post in question...Code:function comments($id){ $result = mysql_query("SELECT * FROM comments WHERE comments.nid = " . $id); $comments = mysql_num_rows($result); return "<a href=comments.php?post=" . $id . ">" . $comments . ($comments == 1 ? "Comment..." : "Comments...") . "</a><br>"; }
however, when there are no comments on this piece of news, num_rows throws a wobbly and prints an error message so screwin' up me page, pah
is there anyway of solving this or getting round this, could i use SELECT count(*) but not sure what that returns and how to print it to the page, ie there are count(*) comments...
please help,
beachball







Bookmarks