Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 639721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:52:26+00:00 2026-05-13T20:52:26+00:00

I am creating dynamic menus and submenus in php…. Can’t know where to start….

  • 0

I am creating dynamic menus and submenus in php…. Can’t know where to start…. I have written all my queries but need suggestion to iterate the result set with Ul and li elements with it…. There may are may not be submenus for submenu and there may or may not be submenus for menus…..

Menu1
  submenu1
     submenu11
     submenu12
  submenu2
     submenu21
Menu2
  submenu1
     submenu11
     submenu12

Any suggestion….

EDIT:

Here is what i am doing,

<?php

      $con=mysql_connect("localhost","root","");
      $db=mysql_select_db("testt");

      echo '<ul id="nav">';
      $res=mysql_query("SELECT * FROM menu WHERE PARENT_ID=0");
      while($row=mysql_fetch_array($res))
      {
            echo '<li class="top"><a href="#" class="top_link"><span>'.$row['MENU_NAME'].'</span></a></li>';
            $res1=mysql_query("SELECT * FROM menu WHERE PARENT_ID=1 AND CHILD_ID=".$row['ID']."");
            echo '<ul class="sub">';
            while($row1=mysql_fetch_array($res1))
              {
                 echo '<li><a href="#" class="fly">'.$row1['MENU_NAME'].'</li>';
                 $res2=mysql_query("SELECT * FROM menu WHERE PARENT_ID=2 AND CHILD_ID=".$row1['ID']."");
                 echo '<ul>';
                 while($row2=mysql_fetch_array($res2))
                    {
                        echo '<li><a href="#">'.$row2['MENU_NAME'].'</li>';
                    }
                  echo '</ul>';
              }
              echo '</ul>';
      }
      echo '</ul>';





      ?>

Here is my table,

alt text http://img229.imageshack.us/img229/1174/84296639.jpg

My CSS Class doesn't seem to get applied

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:52:27+00:00Added an answer on May 13, 2026 at 8:52 pm

    Edit: Posted before you clarified your question. Here’s a general recursive menu structure.

    <?php
    function print_menu($menu)
    {
      echo "<ul>\n";
      foreach ($menu as $submenu)
      {
        echo "<li>\n";
        echo "<span>{$submenu['name']}</span>\n";
        if (!empty($submenu['children']))
          print_menu($submenu['children']);
        echo "</li>\n";
      }
      echo "</ul>\n";
    }
    
    print_menu(
      array(
        array(
          'name' => 'Menu 1',
          'children' => array(
            array(
              'name' => 'Submenu 11',
              'children' => array(
                array('name' => 'Submenu 111'),
                array('name' => 'Submenu 112')
              )
            ),
          )
        ),
        array(
          'name' => 'Menu 2'
        )
      )
    );
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know what is the best way of creating dynamic queries
I have a feeling I'm being thick, but here's my problem: I'm creating dynamic
I have a scenario that, I am creating dynamic html content and I need
I have a method that generates pop-up menu with many submenus. Basically these menus
I'm creating dynamic website with Php and Mysql. So i need insert bangla language
I'm creating dynamic site with Php and Mysql. I've both English and Bangla content
I have used Android phonegap application for creating dynamic list with label and corresponding
I am creating multilang pages for a dynamic site 9ocial network) so all the
I am creating dynamic web project in Eclipse. I have the .java files in
We have many environments and thinking of creating dynamic application configuration as part of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.