Here are the code
The PHP code is:
$menu=array();
$query="SELECT * FROM domenii WHERE parentid=0";
$resursa=$obj->query($query);
while($row=$obj->fetcharray($resursa)){
$query1="SELECT * FROM domenii WHERE parentid=".$row['id'];
$resursa1=$obj->query($query1);
if($obj->numrows($resursa1)>0){
$submenu=array();
while($row1=$obj->fetcharray($resursa1)){
$submenu[]=array('type'=>$row1['type'],
'id'=>$row1['id'],
'nume'=>$row1['nume'],
'title'=>str_replace(' ','-', $row1['nume']));
}
}else{$submenu='0';}
$menu[]=array('type'=>$row['type'],
'id'=>$row['id'],
'nume'=>$row['nume'],
'title'=>str_replace(' ','-', $row['nume']),
'submenu'=>$submenu);
}
$obj->assign('menu', $menu);
The HTML (with smarty) code:
The PHP code is:
$menu=array();
$query="SELECT * FROM domenii WHERE parentid=0";
$resursa=$obj->query($query);
while($row=$obj->fetcharray($resursa)){
$query1="SELECT * FROM domenii WHERE parentid=".$row['id'];
$resursa1=$obj->query($query1);
if($obj->numrows($resursa1)>0){
$submenu=array();
while($row1=$obj->fetcharray($resursa1)){
$submenu[]=array('type'=>$row1['type'],
'id'=>$row1['id'],
'nume'=>$row1['nume'],
'title'=>str_replace(' ','-', $row1['nume']));
}
}else{$submenu='0';}
$menu[]=array('type'=>$row['type'],
'id'=>$row['id'],
'nume'=>$row['nume'],
'title'=>str_replace(' ','-', $row['nume']),
'submenu'=>$submenu);
}
$obj->assign('menu', $menu);
The HTML (with smarty) code:
Compact it like this:
['main_link1'] => Array (
['key1'] => value
['key2'] => value
['submenus'] => Array (
['sublink1'] => Array ()
['sublink2'] => Array ()
)
['main_link2'] => Array (
['key1'] => value
['key2'] => value
['submenus'] => Array (
['sublink1'] => Array ()
['sublink2'] => Array ()
)
No comments:
Post a Comment