i want to have unlimited menu and submenu and show them like tree as shown at the bottom
My mysql table structure
id //menu ID
title //menu title
parentID //menu parent ID
My PHP code
<select id="sub" name="sub" class="select" style="width:200px;">
<option value="">none</option>
<?
//----------------Get Menu Function---------------
function getMenu($parentID=0)
{
$selectMenus = mysql_query("SELECT * FROM menus WHERE parentID='$parentID'") OR DIE(mysql_error());
if(mysql_num_rows($selectMenus) != 0)
{
while ($rowMenus = mysql_fetch_array($selectMenus))
{
if ($rowMenus['parentID'] != 0)
{
$tab .= "--";
}
else
{
$tab = "";
}
echo "<option value='" . $rowMenus['id'] . "|" . $rowMenus['title'] . "'>" . $tab . $rowMenus['title'] . "</option>";
$menus .= getMenu($rowMenus['id']);
}
}
return $menus;
}
//-----------------------------------------------
echo getMenu();
?>
</select>
I want to add 2 dash in first of submenus of each menu and show them in option of a select box like this
Mainpage
Products
--Granite
----GreenGranite
----BrownGranite
--travertine
AboutUs
Whats wrong with my code?