Doing a query with COUNT * , then showing only distinct values of the query with the count value attached, like "Yellow (23)", dropdown menu.
need script that counts entries with specific criteria then using output to decide to echo text
Aug 6th, 2000 19:24
Jason Wong, Max Palmar, Evan Heller, Onnig Sayadian,
A better way to do this is such:
$result = mysql_query("select blah from bleh where X") or die
$count = mysql_num_rows($result);<br>
if ($row = mysql_fetch_array($result))<br>
print $row["blah"] . "(" . $count . ")"; <br>
} while if ($row = mysql_fetch_array($result))<br>
or you can do this just to get the count included
select count (*) as the_count, blah from bleh where X
ignore the <br> tags..sorry
Thanks for your answer.
When I do this the $count variable just counts the total number of rows
in the array and prints that with each result as it loop through like
meaning it dosnīt count the number of yellows in a column, and greens,
and reds, etc. etc.
I want to show a list of distinct values in a column with the number of
instances of it in the column. Any ideas?
You need to do something like this:
SELECT ColourColumn, COUNT(ColourColumn) FROM YourTable GROUP BY