I have a table in my mysql database that looks like the following:
id | category | title
1 | blue | title1
2 | green | title2
3 | red | title3
4 | purple | title4
5 | red | title5
1 | blue | title1
2 | green | title2
3 | blue | title3
4 | blue | title4
5 | red | title5
.....
I want to echo the category names on my page and then count how many items there are in each category.
Goal is something like this:
blue(4)
green(2)
red(3)
purple(1)
I have tried echoing the categories but I just receive a long list of duplicates. Can anybody point me in the right direction?