Hi Everyone, I am looking for the best way to create a PHP MYSQL Query to help me output a complete list of categories from my db.
The categories are football team names & I would like to display everyone who supports each football team.

For Instance:
I have 44 Manchester Utd fans / 65 Chelsea Fans in my DB.
I would like to group all together like
(Column Name) Manchester United Fans
List all 44 supporters here
(Column Name) Chelsea Fans
List all 65 supporters here

I am using the following

SELECT title, mcat, murl FROM tbl_name GROUP By mcat ORDER BY mcat DESC

Then using a while

while ($row = $stmt->fetchObject()) {

But I am only seeing one for each in my output.
What is it I am doing wrong?

Thanks in advance

The GROUP BY makes a group, so it collapses everything that has the same category. What you want is just the ORDER BY on the supporters table (with a join on the teams table), and adjust your output somewhat. Do you have two tables? One for teams and one for supporters?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.