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.
Maybe this will help. I do all my counts this way. I know there is a better way, but this way works
$query="select COUNT(*) as total from mytable where this='that'";
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!