ya i'm connected to a database and i'm using this code to display the results in a table
PHP Code:
<?php echo "<table border='1'>
<tr>
<th>Product Code</th>
<th>Name</th>
<th>Product Type</th>
<th>Picture</th>
<th>Description</th>
<th>Stock</th>
<th>Price</th>
</tr>";
while($row = @mysql_fetch_array($result))
{
if ($row['Department'] == $var)
{
echo "<tr>";
//echo "<td>" . $row['Department'] . "</td>";
echo "<td>" . $row['Prod_code'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Prod_Type'] . "</td>";
echo "<td><img height = 50 width = 50 src = " . $row['Picture'] . "></td>";
echo "<td>" . $row['Description'] . "</td>";
echo "<td>" . $row['Stock'] . "</td>";
echo "<td>" . $row['Price'] . "</td>";
echo "</tr>";
}
}
echo "</table>";mysql_close($con);
?>
However this lists all the data from the database in a row.
I want to have a heading with each product type in the database in bold and then all the products of that type underneath and then the next type etc.
Like this structure :
Product Type(first prod type in the table)
Name Code Description Stock Picture Price
Name Code Description Stock Picture Price (all items of that prod type)
Name Code Description Stock Picture Price
Name Code Description Stock Picture Price
Product Type (next prod type in table)
Name Code Description Stock Picture Price
Name Code Description Stock Picture Price
Name Code Description Stock Picture Price
Name Code Description Stock Picture Price
I was thinking if i could add all distinct prod types to an array.Then select * from the first element of the array and display, then the same with the next element and so forth. I just cant get my head around coding the loop i need!
thanks