PHP / Mysql Printing sub buttons of buttons
Posted: Tue Jan 10, 2006 4:42 am
Hi,
I have this dynamic menu but i cannot find the way on how to print a sub buttons inside a list.
I would like to achieve:
<ul>
<li> button 1
(echo sub button)
<ul>
<li> sub button 1.1 </li>
</ul>
(finished echo sub button)
</li>
</ul>
This is the php bit i got:
Thanks guys.
RM
I have this dynamic menu but i cannot find the way on how to print a sub buttons inside a list.
I would like to achieve:
<ul>
<li> button 1
(echo sub button)
<ul>
<li> sub button 1.1 </li>
</ul>
(finished echo sub button)
</li>
</ul>
This is the php bit i got:
Code: Select all
<?php
include('common.php');
// Connect to database
dbConnect();
$qry = "select * from menu where menu_parent='' and menu_enabled='Y' order by menu_name asc";
$rst = mysql_query($qry);
echo '<ul>'."\n";
while($row=mysql_fetch_array($rst)) {
echo "\t".'<li><a href="showmenu.php?p='.$row['menu_id'].'">'.$row['menu_name'].'</a>'.'</li>'."\n";
if($_GET['p']==$row['menu_id']) {
$qry2 = "select * from menu where menu_parent='$row[menu_id]' and menu_enabled='Y' order by menu_name asc";
$rst2 = mysql_query($qry2);
while($row2=mysql_fetch_array($rst2)) {
echo '<ul>'."\n";
echo "\t".'<li><a href="showmenu.php?p='.$row['menu_id'].'&pg='.$row2['menu_id'].'">'.$row2['menu_name'].'</a></li>'."\n";
echo '<\ul>'."\n";
}
}
}
echo '</ul>'."\n";
?>RM