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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.