1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$niv_h_tab[$row{'id'}] = $row['num_h'];
$parent_tab[$row{'id'}] = $row['parent'];
$descr_tab[$row{'id'}] = stripslashes($row['description']);
$niv_max = $row['num_h'];
}
$html = "<ul id=\"menu\">";
$niv = 1;
foreach ($niv_h_tab as $key => $value){
if ($value == $niv){
$html .= "<li><a href=\"#\">".$descr_tab[$key]."</a>";
$html .= "<ul>";
foreach ($parent_tab as $key_p => $parent){
if ($parent == $key){
$html .= "<li><a href=\"#\">".$descr_tab[$key_p]."</a></li>";
}
}
$html .= "</ul>";
$html .= "</li>";
}
}
$html .= "</ul>";
echo $html;
} |
Partager