Grouping data with PHP

I have a PHP file that is returning all the values from a MySql Database. They are a list of car types.

The variables are being sent to Flash. I need a way to group this information into similar car types and then a way to tell flash how many there are of each group and how many groups there are.

Something like this:

&grandtotal=30&totalnumberofgroups=5&group1total=4&group1car1=AudiA6&group1car2=AudiA6&group1car3=AudiA6&group1car4=AudiA6&group2total=3&group2car1=BMW 3 Series&group2car2=BMW 3 Series &group2car3 =BMW 3 Series…etc

Is this possible with PHP/MySql?

Any help much appreciated.Thank you.