How do I print an SQL COUNT command?

I am using this SQL query in a PHP page…

$count  = @mysql_query("SELECT COUNT(*) FROM newPhones WHERE phone = 'Nokia'");

…but what do I put in the echo to print the number?
Seems like a simple question to me, but if you don’t know, you don’t know.
Cheers guys!

  • Will

Maybe this will help. I do all my counts this way. I know there is a better way, but this way works :wink:

$query="select COUNT(*) as total from mytable where this='that'";
if($myrow=mysql_fetch_array($results))	{	
echo "Total = ".$myrow["total"]."";

No need to use mysql_fetch_array() here when you are only after one field.

$result  = @mysql_query("SELECT COUNT(*) FROM newPhones WHERE phone = 'Nokia'");
$count = mysql_result($result, 0);

I knew there was a better way! I’m going to throw that in my snippets library!