0

Hi everyone!!

I have a mysql table of products and i want to group them by the category then each sub category in a table:

SQL strng:

SELECT `Product_Name` , `Product_Description` , `Product_Features` , `Product_picurl` , `Product_price` , `Product_Category` , `Product_subcat`
FROM `prod_listing`

Like this:

Acoustic Treatment
Acoustic panels
data
data
Amplifiers
Studio amps
data
data

How can i do thisand still be able to see the table layout in dreamweaver?

thanks in advance

3
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by nav33n
0

You can do that by using group by clause. select * from product_listing group by product_category; I dont know what you mean by >>still be able to see the table layout in dreamweaver << :S

0

you can arrange your output in any format you want.

<?php
//connection
//select db
$query="select * from product_listing group by product_category";
$result=mysql_query($query);
echo "<table>";
while($row=mysql_fetch_array($result)){
   echo "<tr><td>".$row['product_name']."</td><td>".$row['product_id']."</td></tr>";
}
echo "</table>";
?>

This will put the values in a table of 2 columns. I don't understand what the code in your other thread do.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.