Problema risolto! Pubblicherò come è stato fatto e qualcuno potrebbe essere in grado di usarlo.
function menu()
{
global $dbc;
$result = $dbc->prepare('SELECT page, linktext, visable, parent FROM content WHERE visable > 0 ORDER BY parent,sort ASC');
$result->execute();
$result->bind_result($menu_page, $menu_linktext, $menu_visible, $menu_parent);
while($result->fetch())
{
if($menu_parent == 0) $menu[$menu_page]=$menu_linktext;
elseif(!empty($menu[$menu_parent])) $sub[$menu_parent][]=$menu_linktext;
}
$result->close();
if(!empty($menu))
{
echo '<ul class="sf-menu" id="nav">';
foreach($menu as $page=>$link)
{
echo "<li><a href='$link'>$link</a>";
if(!empty($sub[$page]))
{
echo '<ul>';
foreach($sub[$page] as $lnk) echo "<li><a href='$lnk'>$lnk</a></li>";
echo '</ul>';
}
echo '</li>';
}
echo '</ul>';
}
}