PDA

View Full Version : Array and sort


david07
02-05-2006, 06:20 AM
I have products that belong to certain categories. I want to array the product (mysql_fetch_array), and ORDER BY the Category they belong to. However I dont want the category to array each time.

I want
CATEGORY ONE | CATEGORY 2
product one | product one
product two | product two

The code i am using is --

$query = "SELECT category.cat_id, category.catname, inventory.cat_id, inventory.product, FROM category INNER JOIN inventory ON category.cat_id = inventory.cat_id ORDER BY catname ASC";
.................
while($row = mysql_fetch_array($result)){

echo "<tr><td>";
echo $row['catname'];
echo "</td><td>";
echo $row['product']; ETC

How can i array the products with out the Category, but have category as a heading??? where the arrayed products will go under.