Опитайте това:
list($count) = mysql_fetch_row(mysql_query("select count(*) from `test`"));
echo $count;
Като алтернатива, ако вече изпълнявате заявка, за да получите някои коментари, можете да опитате това:
$sql = mysql_query("select sql_calc_found_rows * from `test` order by `id` desc limit 10");
// ^ Get the 10 most recent comments
list($count) = mysql_fetch_row(mysql_query("select found_rows()"));
// this avoids having to run the entire query again, great for efficiency!
while($comment = mysql_fetch_assoc($sql)) var_dump($comment); // just an example