I am trying to get the sub-sections of sections recursively from the database. Right now, my code only gets the parents but not the children though. What modification do I have to do to this code to accomplish my goal? Thanx
function getSections()
{
$this->connectToDB();
// get list of sections that has no parents
$sql ="SELECT * FROM sections WHERE parent = 0 ORDER BY id ASC";
$result = mysql_query($sql);
while($row=mysql_fetch_array($result))
{
$thisID = $row['id'];
// recursivly get childeren
$childeren = $this->recursivlyGetSections($thisID);
// add to the final result
$toReturn .= "$thisID<br>$childeren";
}
// return final result
return $toReturn;
}