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

  • Home
  • SEARCH
  • 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 4023756
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:38:15+00:00 2026-05-20T10:38:15+00:00

I currently have some VERY long winded code for the menu I use on

  • 0

I currently have some VERY long winded code for the menu I use on my site.
My website
It’s almost 2000 lines long lol. I think I may be able to use a switch but I’ve tried and cannot implement it to work properly.

On each menu when you click a button it stays highlighted, telling the user that they are on that page. The only way I could get this to work was like so…

if($subject == 'art') {
echo '<div id="spacer2"><br></div>';
echo '<div class="idName2" id="menu2">';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=all&listtype='.$listtype.'">All</a>';
echo '<div id="spacer2"><br></div>';
echo '</div>';
echo '<div class="idName3" id="menu3">';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=art&listtype='.$listtype.'">Art</a>';
echo '</div>';
echo '<div class="idName2" id="menu2">';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=biology&listtype='.$listtype.'">Biology</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=english&listtype='.$listtype.'">English</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=chemistry&listtype='.$listtype.'">Chemistry</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=mathematics&listtype='.$listtype.'">Mathematics</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=history&listtype='.$listtype.'">History</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=religion&listtype='.$listtype.'">Religion</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=geography&listtype='.$listtype.'">Geography</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=music&listtype='.$listtype.'">Music</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=philosophy&listtype='.$listtype.'">Philosophy</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=psychology&listtype='.$listtype.'">Psychology</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=economics&listtype='.$listtype.'">Economics</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=sociology&listtype='.$listtype.'">Sociology</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=technology&listtype='.$listtype.'">Technology</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=electronics&listtype='.$listtype.'">Electronics</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=food&listtype='.$listtype.'">Food</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=law&listtype='.$listtype.'">Law</a>';
echo '<a href="browse.php?alphabet='.$alphabet.'&subject=politics&listtype='.$listtype.'">Politics</a>';
echo '</div>';
}

elseif($subject == 'biology') {

and then there’s however many ‘elseifs’ as there are menu items, which ends up totalling to 2000 lines of code which is obviously very inefficient and it also makes it unbelievably time consuming to change anything… can someone point me in the right direction in what I need to do please!

  • 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-20T10:38:16+00:00Added an answer on May 20, 2026 at 10:38 am

    Navigation is always a pain. Here is a simple solution that might help.

    Put everything in an array, like this:

    $menu = array(
        'All' => '/browse ...',
        'Art' => '/browse ... art',
        'Biology' => '/browse ... biology',
        // etc.
    )
    

    Then, you can build all the links based on the current subject:

    $subject = 'Art';
    
    foreach ($menu as $title => $url) {
        if ($title == $subject) {
            echo "<b>$title</b><br>\n";
        } else {
            echo "<a href=\"$url\">$title</a><br>\n";
        }
    }
    

    This is a rather simplistic solution, but it can be extended to create a more complicated menus structure.

    Another solution you could look at is Zend_Navigation.
    http://framework.zend.com/manual/en/zend.navigation.introduction.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have some code that will produce a crash dump when my application
I currently have some code that pulls down a list of users in a
I've been trying to implement unit testing and currently have some code that does
Currently, I have some basic code to play a simple tone whenever a button
I currently use Strawberry Perl as my primary Perl distribution. However, I have some
We currently have some code to extract digits from an int, but I need
I'm tinkering with Silverlight 2.0. I have some images, which I currently have a
I currently have a SQL Server (Express 2005) database to hold some transaction/metadata that
I'm currently working on project with Haskell, and have found myself some trouble. I'm
I have a challenge I need some input on. I am currently recruiting programmers

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.