Code Help
Posted: Wed Nov 12, 2008 11:31 am
Hi
I need some help with this code........
$result = mysql_query("SELECT Distinct SubProduct, Product FROM Table Order by PRODUCT");
while($row = mysql_fetch_array($result))
{
echo " " .$row['Product']. " ";
echo " " .$row['SubProduct']. " ";
}
This gives me the following output
Products 1 SubProduct 1
Products 1 SubProduct 2
Products 1 SubProduct 3
Products 1 SubProduct 4
Products 2 SubProduct 1
Products 2 SubProduct 2
Products 2 SubProduct 3
Products 2 SubProduct 4
However I would like to display the information this way with the Product name only displaying once like this
Product 1
SubProduct 1 SubProduct 2 SubProduct 3 SubProduct 4
Product 2
SubProduct 1 SubProduct 2 SubProduct 3 SubProduct 4
Can anoyone show me what I need to do the the code to get my information to display the way I want it?
I need some help with this code........
$result = mysql_query("SELECT Distinct SubProduct, Product FROM Table Order by PRODUCT");
while($row = mysql_fetch_array($result))
{
echo " " .$row['Product']. " ";
echo " " .$row['SubProduct']. " ";
}
This gives me the following output
Products 1 SubProduct 1
Products 1 SubProduct 2
Products 1 SubProduct 3
Products 1 SubProduct 4
Products 2 SubProduct 1
Products 2 SubProduct 2
Products 2 SubProduct 3
Products 2 SubProduct 4
However I would like to display the information this way with the Product name only displaying once like this
Product 1
SubProduct 1 SubProduct 2 SubProduct 3 SubProduct 4
Product 2
SubProduct 1 SubProduct 2 SubProduct 3 SubProduct 4
Can anoyone show me what I need to do the the code to get my information to display the way I want it?