0
我在PHP中有一個關聯數組。 下面是代碼:smarty中的多級菜單
$result = mysql_query("SELECT * FROM `tb_menu` ORDER BY id ASC");
$menu = array();
$menu_index = array();
while($row = mysql_fetch_assoc($result)){
if($row['par'] == 0) {
$menu[] = $row;
$menu[sizeof($menu)-1]['child'] = array();
$menu_index[$row['id']] = &$menu[sizeof($menu)-1];
} else {
$menu_index[$row['par']]['child'][] = $row;
$menu_index[$row['id']] = &$menu_index[$row['par']]['child'][sizeof($menu_index[$row['par']]['child'])-1];
}
}
/*print ('<pre>') ;
print_r ($menu) ;
print ('</pre>') ; exit();*/
$smarty->assign('menu', $menu);
我不能讓它在Smarty的工作,因爲我在這一個初學者。 請幫我做出這樣的多級菜單
<ul>
<li><a href="">first level</a>
<ul>
<li><a href="">second level</a></li>
......................................
<ul>
<li><a href="">N-level</a></li>
<ul>
</ul>
</li>
</ul>
</li>
感謝