Forum Moderators: open
$result = mysql_query($query) or die("Couldn't execute query because: ".mysql_error());
while ($data = mysql_fetch_array($result)){
$posts = $data['COUNT(albumname)'];
}
{
echo "$user has $posts post(s)";
}
The problem is that I have 6 lines in the database that have the same value for "albumname" and of course they are counted seperately. What I want is for the script to recognize that all 6 lines are exactly the same and only read them as 1.
$query = "SELECT user, COUNT(DISTINCT(albumname))
FROM albuminfo
ORDER BY albumname";
$result = mysql_query($query) or die("Couldn't execute query because: ".mysql_error());
while ($data = mysql_fetch_array($result)){
$posts = $data['COUNT(DISTINCT(albumname))'];
}
{
echo "$user has $posts post(s)";
}
And now I am getting this error:
Couldn't execute query because: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
HELP!
[edited by: Spiceydog at 11:22 pm (utc) on July 8, 2008]
$query = "SELECT user, COUNT(user) FROM albuminfo GROUP BY albumname ORDER BY albumname";