Jump to content

This tree menu


dhimok

Recommended Posts

Hello, Can someone help me with this recursive function. As the function is right now it shows all parents and children. What I want to do is to expend parent to show children and when i click on a child then the menu does not collapse but remains. any ideas? thanks in advance

 

function menu($parent = 0, $level = 0)
{
   // where parent of 0 means it's top-level
   $retval = "";

   $sql = mysql_query("SELECT * FROM " . TABLE_CATEGORIES . " WHERE parent='$parent'  ORDER BY sort ASC");

	$retval .= "<div id=\"verticalMenu\">\n";
	$retval .= "<ul>\n";

   while ($row = dbFetchAssoc($sql))
  	{
    	extract($row);
        $retval .= "<li><a href=\"".friendlyURL($category_id)."\">" .$category."</a></li>\n";

	$retval .= menu($category_id, intval($level) + 1);
   }
   		$retval .= "</ul>\n";
	$retval .= "</div>\n";

   return $retval;
}

Link to comment
https://forums.phpfreaks.com/topic/46180-this-tree-menu/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.