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

Recommended Answers

All 4 Replies

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

i dont think you can view the table in dreamweaver once it is in the <?php ?> code.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.