Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Get all Top menu items from database (where submenu is #)
- $menuSql = "SELECT id, Overskrift FROM Pages WHERE submenu = '#' ORDER BY id ASC";
- $menuResultSet = mysql_query($menuSql) or die(mysql_error());
- // For each of the Top menu items output it and see if there are sub menu items associated with it
- while ($menuTopic = mysql_fetch_assoc($menyResultSet)) {
- echo "<ul>";
- echo "<li><a href='?pageid={$menuTopic['id']}'>{$menuTopic['Overskrift']}</a></li>";
- // check for sub menu items here
- $subSql = "SELECT id, Overskrift FROM Pages WHERE submenu != '#' AND menu = {$menuTopic['id']} ORDER BY id ASC";
- $subResultSet = mysql_query($subSql) or die(mysql_error());
- // check the number of sub menu items for this Top menu items
- if (mysql_num_rows($subResultSet) > 0) {
- // if it has more than 0, output them too
- echo "<li><ul>";
- while ($subMenu = mysql_fetch_assoc($subResultSet)) {
- echo "<li><a href='?pageid={$menuTopic['id']}'>{$menuTopic['Overskrift']}</a></li>";
- }
- echo "</ul></li>;
- }
- echo "</ul>";
- }
- ?>
Add Comment
Please, Sign In to add comment