Page 1 of 1

mysql query help

Posted: Thu May 26, 2005 6:04 am
by adrian29uk
I have worked out how to display and group the cars from the database and output this to the page using the following query

$query = "SELECT manufacturer, count(*) AS cnt FROM manufacturers_table WHERE manufacturer= '$manufacturer' GROUP BY manufacturer";

When it outputs it shows me the manufacturer and how many cars the manufacturer has for example

ford (3)

vauxhall (2)


What I would like to able to show is the car models directly underneath the manufacturer and group by models for example

Ford (3)
Fiesta (2), Escort (4), Kar (2)

vauxhall (2)
Vectra (4), Corsa (2)

I have tried and tried with the query but I still cannot get it. If anyone could show me some examples that would be appreciated.

Thank you in advance

Posted: Thu May 26, 2005 6:14 am
by JayBird
1) How about posting in the correct section
2) Read this - viewtopic.php?t=21171
3) Need to see your DB structure