SELECT Count - solved
| From: | margor777@yahoo.com | Date: | Thu, 06 Nov 2003 05:28:30 +0000 |
| Subject: | SELECT Count - solved | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-31470@lists.php.net to get a copy of this message | ||
Thanks for the debug advice - I will start using my_sql_error
First I got this error:
Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no
GROUP BY clause
So the correct code ended up:
$sql = "SELECT COUNT(bandid), genre
FROM bands, genre
GROUP BY genre";
$result=mysql_query($sql) or die(mysql_error());
$num=mysql_fetch_row($result);
echo $num[0];
while ($gen=mysql_fetch_row($result)) {
echo $gen[1];
}
Thanks guys
---------------------------------
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard