Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[SQL]Grabbing the number of comments

Experienced Elementalist
Joined
Apr 15, 2008
Messages
256
Reaction score
0
Im trying to make the results look like:
Comments(84) where 84 would be how many records there is in the comments table where news_id is 1
PHP:
<a href="index.php?comment=<?php echo($data['ID']) ?>">Comments(
		  <?php
		   $counta=mysql_query("SELECT count(comments) FROM comments WHERE news_id='".$data['id']."'") or die(mysql_error());
		  $query=mysql_query("SELECT count(comments) FROM comments WHERE news_id='".$data['id']."'") or die(mysql_error());
		  ?></a>)
 
Experienced Elementalist
Joined
Dec 27, 2006
Messages
288
Reaction score
4
I don't really understand since you don't clearly state your problem.

Here's how I would do it (not really):

PHP:
<a href="index.php?comment=<?php echo($data['ID']) ?>">Comments(<?php echo mysql_result(mysql_query("SELECT COUNT(*) FROM comments WHERE news_id = '{$data['id']}'"), 0, 0) ?>)
 
Back
Top