Jump to content

Building a menu


bravo14

Recommended Posts

Hi Guys

 

I am trying to build a menu sing the code below, I can get the main headings, the problem arises when I try and produce the sub menus.

 

Can someone please tell me where I am going wrong, or a better way of getting the desired result

<?php
function submenu()
{
     $submenu_sql=mysql_query("SELECT * FROM `tbl_menu` where `parent_menu_id` = '$menu_row[menu_id]'");
     if(mysql_num_rows($submenu_sql)>0)
     {
         echo('<ul>');
         while
         ($submenu_row=mysql_fetch_assoc($submenu_sql))
         {
             echo('<li><a href="'.$submenu_row['link'].'">'.$submenu_row['menu_display'].'</a></li>');
             }
             echo('</ul>');
             };
             }

$menu_sql=mysql_query("SELECT * FROM `tbl_menu` where `parent_menu_id` = '0'");
if (mysql_num_rows($menu_sql)>0)
{
    echo('<div id="accordian">');
    while ($menu_row=mysql_fetch_assoc($menu_sql))
    {
        echo('<div class="panel_container">
        <h3><a href="'.$menu_row['link'].'">'.$menu_row['menu_display'].'</a></h3>
        <div class="panel_body">');
        submenu();
        echo('</div>
        </div>');
        }
        echo('</div>');
        }
        ?>

 

I am getting the following error

Notice: Undefined variable: menu_row in /home/sites/j-slink.co.uk/public_html/includes/menu.php on line 4

 

The desired result is to produce a menu with the following layout

<div id="accordion">



<div class="panel_container" id="panel1">
    <h3 id="visible">Home</h3>
    <div id="panel1-body" class="panel_body">
    </div>
</div>

<div class="panel_container" id="panel2">

    <h3>Music</h3>
    <div id="panel2-body" class="panel_body">
        <div>
        <ul>
<li>Calling Card Mixing Tape</li>
</ul>
        </div>
    </div>

</div>

<div class="panel_container" id="panel3">
    <h3>Panel 3</h3>
    <div id="panel3-body" class="panel_body">
        <div>
        This is the contents of this panel.
        </div>
    </div>
</div>

<div class="panel_container" id="panel4">
    <h3>Panel 4</h3>
    <div id="panel4-body" class="panel_body">
        <div>
        This is the contents of this panel.
        </div>
    </div>
</div>

<div class="panel_container" id="panel5">
    <h3>Panel 5</h3>
    <div id="panel5-body" class="panel_body">
        <div>
        This is the contents of this panel.
        </div>
    </div>
</div>

</div>

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/221203-building-a-menu/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.