Now, I want to list all authors like this:
Author - Number of comments
-----------------------------
Author1 - 10
Author2 - 3
Author3 - 23
-----------------------------
I tried to do it like this:
Code: Select all
<table>
<tr>
<td><strong>Author</strong></td>
<td><strong>Number of comments</strong></td>
</tr>
<?php
mysql_connect('xxx','xxx','xxx') or die("mysql error");
mysql_select_db("xx") or die("mysql error");
$all = mysql_query("SELECT author FROM comments");
while($fetch = mysql_fetch_array($cs_all)) {?>
<tr>
<td><strong><?php echo $fetch['author']; ?></strong></td>
<td><?php echo mysql_num_rows(mysql_query("SELECT author FROM comments WHERE author='".$fetch['author']."'")); ?></td>
</tr>
<?php }?>
</table>Thanks.