This function will get you started:
get_childs($menu_id) {
$resp=array();
$res=mysql_query("SELECT * FROM menu_items WHERE menu_parent_id='$menu_id'");
if(mysql_num_rows($res)) {
for($i=0;$tmp=mysql_fetch_array($res); $i++) {
$resp[$i]['menu']=$tmp; // ['menu'] will contain info about particular menu item
$resp[$i]['childs']=get_childs($tmp['menu_id']); // ['menu'] will contain all childs of this menu items, each child will again contain ['menu'] and ['childs'] etc.
}
}
return $resp;
}
$menu_tree = get_childs(0);
echo '<pre>';
print_r($menu_tree);
echo '</pre>';
Cesar Aracena wrote:
Hi all,
I'm making a new site for a client and he needs to put several different
menus under a static FLASH menu. The bad part is that every item in the
flash menu leads to different categories and these need different number
of sub menus. I use MySQL & PHP 4. The categories and sub categories are
something like this:
* Products <-- Flash static menu
- Item 1 <-- MySQL fetched menu
- Item 2 <-- MySQL fetched menu
- Item 3 <-- MySQL fetched menu
- Item 3-1 <-- MySQL fetched menu
- Item 3-2 <-- MySQL fetched menu
* Services <-- Flash static menu
- Item 1 <-- MySQL fetched menu
- Item 1-1 <-- MySQL fetched menu
- Item 1-2 <-- MySQL fetched menu
- Item 2 <-- MySQL fetched menu
- Item 3 <-- MySQL fetched menu
What would be the best solution for this? Another problem to solve is
the creation of new children into the menu... sub categories AND items
dynamically.
Thanks in advance,
Cesar L. Aracena
[EMAIL PROTECTED]
[EMAIL PROTECTED]
(0299) 156-356688
Neuquén (8300) Capital
Argentina
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php