The following code lists each of the caritems each line at a time - displaying the carname on each line: (echo mysql_result($result, $i, 'carname') . " > ";
Instead of displaying the carname on each line, how would I make it so it groups the caritems together by carname and then displays the carname once at the top with each of the caritems associated with that carname displayed below... It would then move on to the next carname, grouping items...
$result = mysql_query("SELECT * FROM cars LEFT JOIN caritems ON cars.carid = caritems.carid ORDER BY cars.carsortorder ASC");
$total_results = mysql_num_rows($result);
for ($i = 0; $i < 1500; $i++)
{
if ($i == $total_results) { break; }
$rowid = mysql_result($result, $i, 'caritems.caritemid');
echo mysql_result($result, $i, 'carname') . " > ";
echo "<div class='carved' />";
echo "<strong class='caritemheader'>" . mysql_result($result, $i, 'caritemname') . " " . mysql_result($result, $i, 'caritemprice') . "</strong><br />";
/* CHECK IF BLOB EXISTS AND IF SO DISPLAY IMAGE */
if (strlen(mysql_result($result, $i, 'caritempicture'))>0) { echo '<br />' . '<img src="data:image/png;base64,' . base64_encode(mysql_result($result, $i, 'caritempicture')) . '"/>' . '<br />'; }
echo mysql_result($result, $i, 'caritemdescription') . "<br /><br />";
echo "</div>";
}