Simple recursive function
Posted: Mon Jun 02, 2008 12:35 pm
I'm trying to build a recursive function to build a tree-style navigation area. Right now I'm just trying to loop out the entries from their database, loading any children nodes below their respective parents. Any idea why this only lists the top level items and won't go any further?
Code: Select all
function buildNavStructure($System, $navParent, $navLevel)
{
$sql_query = "SELECT * FROM " . $System["tblPrefix"] . "_navigation WHERE navParent=" .
$navParent . " ORDER BY navPosition";
$rs = mysql_query($sql_query);
if (!empty($rs))
{
while($row = mysql_fetch_array($rs))
echo($row["navText"] . "<br />");
// Check for babies...
buildNavStructure($System, $row["navID"], $navLevel+1);
}
}