Jump to content

Grouping A Query Output? .... Anyone Know How To Accomplish This?


skaterdav85

Recommended Posts

so i have some data in my mysql database:name | type----------------playstation | ToyBlouse | Clothingapple | Foodnintendo | Toypants | Clothinghot dog | FoodI want to output it in groups so that on my page it looks something like this:ToyplaystationnintendoClothingBlousepantsFoodapplehot dogthis is my php code so far, but it just outputs each row in the table. But I only want one heading for each type.

$query = "SELECT type, name FROM products ORDER BY type DESC"; $result = mysql_query($query) or die(mysql_error());// Print out resultwhile($row = mysql_fetch_array($result)){ echo "<b>".$row['type']."</b><br/>"; echo $row['name']; echo "<br />";}
Anyone know how to accomplish this?
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...