1) Script Title: Drill Down Menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...lldownmenu.htm

3) Describe problem:
I went this far to make the drill down menu extract categories and its childs subcategories. Everything looks good and ok beside one thing : The drilling is not stopping ; I mean with this code it's as if every category has a child when it's not true, in the end there must be a category that should stop the menu to go further and when clicked open the page.

This is the code :
Code:
<ul id="rootmenu">

<?php
$query = "SELECT catId, catParentId, CatName 
          FROM categories 
          ORDER BY catName";
          
$result = mysql_query($query);
 
$categories = array(); 
while($row = mysql_fetch_array($result)) 
{
	$categories[] = array(
                      	'parent_id' => $row['catParentId'],
                      	'categorie_id' => $row['catId'],
                      	'nom_categorie' => $row['CatName']
                	     );
}

function show_menu($parent, $niveau, $array) 
{ 
$html = ''; 
foreach ($array AS $noeud) 
{ 
     if ($parent == $noeud['parent_id']) 
{ 

// if it's a category with no child...  
        
$html .= '<li>';
$html .= '<a href="index.php?id='.$noeud['categorie_id'].'">';        
$html .= $noeud['nom_categorie'];
$html .= '</a>';

//... There should be   : $html .= '</li>';  here

// This way, the menu will not go further anymore

// but

// if the category has some subcategories as child, it will go like this :

$html .= "<ul>";  
$html .= '<li>';
$html .= show_menu($noeud['categorie_id'], ($niveau + 1), $array);
$html .= '</li>';
$html .= "</ul>";   
$html .= '</li>';
        
    	}
    } 
    return $html; 
}

echo afficher_menu(0, 0, $categories);
?> 
</ul>
I really hope that there will be some php Ninja here who can change this code so the Drill Down Menu can be a DYNAMIC Drill Down Menu !

Thanks for your hard work.