Thats it... I'll have to paste my laughable code in here, the following 'works' but im sure it is far from best practice.
$sectorList = array();
$subSectorList = array();
$specificSubSectors = array();
foreach($query->result as $row) {
if ($row['parent_id'] == 0 ) {
$sectorList[] = array('sector' => $row['cat_name'], 'id' => $row['cat_id'], 'parent' => $row['parent_id']); // Build sector list
} else {
$subSectorList[] = array('sector' => $row['cat_name'], 'id' => $row['cat_id'], 'parent' => $row['parent_id']); // Build sub-sector list
}
}
foreach ($sectorList as $sector) { // Loop sector list
echo $li."<a href=\"".$template."/".$queryString."\">".$sector['sector']."</a>";
if ($subSectorList) {
foreach ($subSectorList as $subSector) {
if ($subSector['parent'] == $sector['id']) {
$specificSubSectors[] = array('sector' => $subSector['sector'], 'id' => $subSector['id'], 'parent' => $subSector['parent']);
}
}
}
if ($specificSubSectors) {
echo "<ul class=\"subSectors\">";
foreach ($specificSubSectors as $specificSubSector) {
echo $li."<a href=\"".$template."/".$queryString."\">".$specificSubSector['sector']."</a>";
}
echo "</ul>";
}
$specificSubSectors = array();
echo "</li>";
}