I have put a page up at http://abc-widgets.i-cre8.com/nested-recordset.php that shows all the records produced by this recordset code:
SELECT manufacturer.manDesc, models.modelDesc, engine.engineSize FROM manufacturer INNER JOIN models ON (manufacturer.manID = models.manID) INNER JOIN model_engine ON (models.modelID = model_engine.modelID) INNER JOIN engine ON (engine.engineID= model_engine.engineID) ORDER BY manufacturer.manDesc, models.modelDesc, engine.engineSize
I am trying to produce a nested list containing manufacturer / model / engine sizes as shown on the page and using a tutorial I found here http://cookbooks.adobe.com/post_Create_nested_lists_from_a_recordset_PHP-16720.html I have got this far:
// get the first row from the recordset
$row_rsCars = mysql_fetch_assoc($rsCars);
echo "<ul>";
// initialize variables
$previousManufacturers = '';
$continueManufacturers = true;
do {
// if not the same value as $previousManufacturers
if ($row_rsCars['manDesc'] != $previousManufacturers) {
// if not the first time, close the nested list
if (!$continueManufacturers) {
echo "</ul></li>";
}
// display the manufacturer
echo "<li>{$row_rsCars['manDesc']}";
echo "<ul>";
$previousManufacturers = $row_rsCars['manDesc'];
}
echo "<li>{$row_rsCars['modelDesc']}";
//start engine size
echo "</li>";
$continueManufacturers = false;
} while ($row_rsCars = mysql_fetch_assoc($rsCars));
echo "</ul></li></ul>";
which gives me manufacturers / models but for the life of me I cannot get the logic right to produce the 3rd list containing the engine sizes.
Any help would be greatly appreciated.