So I have a page which lists a number of products along with the supplier. Each product also falls into one of 3 categories (long-life, short-life, organic).
When displaying the entire product list I want to be able to goup all the long-life products together, followed by short-life then organics, e.g.
Long-Life
=========
Product A Supplier
Product B Supplier
Short-life
==========
Product C Supplier
Product D Supplier
From what I can tell, GROUP BY is not valid for this kind of thing and the only other function I can see that might work is foreach() but I'm not even sure how to do that!
My code so far is:
$select = mysql_query("
SELECT products.*, prodtypes.prodtype
FROM products
LEFT JOIN prodtypes ON prodtypes.typeID=products.type
ORDER BY prodID
",$connection)
or die("Couldn't execute SELECT query: ".mysql_error());
while ($row = mysql_fetch_array($select)) {
[code output here]
}
Any help/guidance on this would be greatly appreciated.
James