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

2 Years
Discussion Span
Last Post by pritaeas

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?

Edited by pritaeas

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.