I give up...I'm going blind and it is probably really stupid.
Situation: I have items that belong to categories. Would liek to display items in chunks of categories.
ie:
Category 1
Product 11245
Product 25325
Category 2
Product 11154
etc...
Table 1: Products
Table 2: Category
Queries:
$prodresult = mysql_query("select * from PRODUCTS order by CATEGORY desc");
$prodnum_results = mysql_num_rows($prodresult);
$tcatresult = mysql_query("select * from CATEGORY");
<?
while ($cattitle = mysql_fetch_array($tcatresult))
{
echo "<tr><td colspan='9' class='maintext'><b>" . $cattitle['NAME'] ."</b></td></tr>";
while($prodrow = mysql_fetch_array($prodresult)){
if($prodrow['CATEGORY'] == $cattitle['CATEGORY'])
{
echo "<tr bgcolor='#FFFFFF' style='padding-left:10px;'>";
echo "<td class='xsmalltext'><b>". $prodrow['CODE'] . "</b></font></td>";
echo "<td class='xsmalltext'><b>". $prodrow['NAME'] . "</b></font></td>";
echo "<td class='xsmalltext'><b>". $prodrow['SUBNAME'] . "</b></font></td>";
echo "<td class='xsmalltext'><b>". $prodrow['SIZE'] . "</b></font></td>";
echo "<td class='xsmalltext'><b>". $prodrow['DESCRIPTION'] . "</b></font></td>";
echo "<td class='xsmalltext'><b>". $prodrow['COST'] . "</b></font></td>";
echo "<td class='xsmalltext'><b>";
echo "<a href='update_product.php?id=";
echo htmlspecialchars( stripslashes($prodrow['CODE']));
echo "'>Update</a>";
echo "</b></font></td>";
echo "<td class='xsmalltext'><b>";
echo "<a href='delete_product.php?id=";
echo htmlspecialchars( stripslashes($prodrow['CODE']));
echo "'>Delete</a>";
echo "</b></font></td></tr>";
}
}
}
?>
What have I got backwards??? The categories are showing but not the items...or at least not all of them.
Thanks in advance