/    Sign up×
Community /Pin to ProfileBookmark

Build a dynamic mega drop down menu using php

I’m Anil kumar i want to build a dynamic mega drop down menu using PHP.

how to create table structure?

how to write the code for doing this?

please help me.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJul 04.2013 — Usually you start by writing something and then showing us. Then we help you correct it.
Copy linkTweet thisAlerts:
@Nicholas_DiazJul 05.2013 — I agree with Gin.. But to try to answer your question...

if what your asking is how to build a navigation bar with drop down links with php.

  • 1. Build the navbar with drown down link linking to what ever page you want.


  • 2. create each page you want and then create a variable at the top of each page using php. something like this at the top of each page

    <?php $page = 'home'; ?>



  • 3. create a nav bar in a page called nav.php that is basically a navigation bar using else and if statements in order to call on what link is active by referencing the variable for each page you have assigned. it will look like this.


  • &lt;ul&gt;
    &lt;?php if ($page == 'home') { ?&gt;&lt;li class="active"&gt;&lt;a href="index.php" class="active"&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;?php } else { ?&gt;&lt;li&gt;&lt;a href="index.php"&gt;Home&lt;/a&gt;&lt;?php } ?&gt;

    &lt;?php if ($page == 'contact') { ?&gt;&lt;li class="active"&gt;&lt;a href="contact.php" class="active"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
    &lt;?php } else { ?&gt;&lt;li&gt;&lt;a href="contact.php"&gt;Contact Us&lt;/a&gt;&lt;?php } ?&gt;

    &lt;?php if ($page == 'services') { ?&gt;&lt;li class="active"&gt;&lt;a href="services.php" class="active"&gt;Services&lt;/a&gt;&lt;/li&gt;
    &lt;?php } else { ?&gt;&lt;li&gt;&lt;a href="services.php"&gt;Services&lt;/a&gt;&lt;?php } ?&gt;

    &lt;?php if ($page == 'employees') { ?&gt;&lt;li class="active"&gt;&lt;a href="employees.php" class="active"&gt;Employees&lt;/a&gt;&lt;/li&gt;
    &lt;?php } else { ?&gt;&lt;li&gt;&lt;a href="employees.php"&gt;Employees&lt;/a&gt;&lt;?php } ?&gt;

    &lt;?php if ($page == 'dashboard') { ?&gt;&lt;li class="active"&gt;&lt;a href="dashboard.php" class="active"&gt;Dashboard&lt;/a&gt;&lt;/li&gt;
    &lt;?php } else { ?&gt;&lt;li&gt;&lt;a href="dashboard.php"&gt;Dashboard&lt;/a&gt;&lt;?php } ?&gt;
    &lt;/ul&gt;


    now no matter what page your own the php with identify it by recognizing the variable you have set and then you can use css to do things with the nav bar to make it super duper doooooo
    ×

    Success!

    Help @anil14353 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.4,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...