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 1051081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:52:25+00:00 2026-05-16T16:52:25+00:00

I have an HTML menu and i have styled it with CSS to highlight

  • 0

I have an HTML menu and i have styled it with CSS to highlight the current page. as i have more then 8 pages using the same code. i wanted to do something dynamic and i created a PHP function for that,

here is my code..

 <?php    function hiddenmenu($activeicon1 = 0, $activeicon2 = 0, $activeicon3 = 0, $activeicon4 = 0,
                               $activeicon5 = 0, $activeicon6 = 0, $activeicon7 = 0, $activeicon8 = 0, $activeicon9 = 0) {
 ?>

                    <div class="icon-no-spacer">
                        <p><a id="<?php echo $activeicon1; ?>" href="index.php" title=""><img src="images/icons/48/display.png" alt="" />Dashboard</a></p>
                    </div>

                    <div class="icon-spacer">
                        <p><a id="<?php echo $activeicon2; ?>" href="post-news.php" title=""><img src="images/icons/48/text_rtf.png" alt="" />Post News</a></p>
                    </div>

                    <div class="icon-spacer">
                        <p><a id="<?php echo $activeicon3; ?>" href="news.php" title=""><img src="images/icons/48/wordprocessing.png" alt="" />News</a></p>
                    </div> 

                    <div class="icon-spacer">
                        <p><a id="<?php echo $activeicon4; ?>" href="post-advertisement.php" title="" ><img src="images/icons/48/view_pim_news.png" alt="" />Post Ad</a></p>
                    </div>

                    <div class="icon-spacer">
                       <p><a id="<?php echo $activeicon5; ?>" href="advertisement.php" title=""><img src="images/icons/48/view_pim_tasks.png" alt="" />Advertise</a></p>
                    </div>

                    <div class="icon-spacer">
                        <p><a id="<?php echo $activeicon6; ?>" href="comments.html" title=""><img src="images/icons/48/spread.png" alt="" />Comments</a></p>
                    </div>

                    <div class="icon-spacer">
                        <p><a id="<?php echo $activeicon7; ?>" href="#" title=""><img src="images/icons/48/rss_tag.png" alt="" />Sponsors</a></p>
                    </div>

                    <div class="icon-spacer">
                        <p><a id="<?php echo $activeicon8; ?>" href="#" title=""><img src="images/icons/48/fileview_preview.png" alt="" />Video</a></p>
                    </div>

                    <div class="icon-spacer">
                        <p><a id="<?php echo $activeicon9; ?>" href="information.php" title="" ><img src="images/icons/48/help_about.png" alt="" />Information</a></p>
                    </div> 
<?php                  
}              
?>

the code is working perfectly fine. is it ok to go with this. ?? lot of people might have come accross this type of issue i want to know the best feasible solution for this..

thank you

  • 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-16T16:52:26+00:00Added an answer on May 16, 2026 at 4:52 pm

    I would do at least these 2 things differently:

    1. separate the definition of the menu items from the rendering, for easier maintenance.
    2. only render available choices to avoid structural errors.

    Something like this can do that:

    <?php
    $choices = array(
        1 => array("index.php",              "display.png",          "Dashboard"),
        2 => array("post-news.php",          "text_rtf.png",         "Post News"),
        3 => array("news.php",               "wordprocessing.png",   "News"),
        4 => array("post-advertisement.php", "view_pim_news.png",    "Post Ad"),
        5 => array("advertisement.php",      "view_pim_tasks.png",   "Advertise"),
        6 => array("comments.html",          "spread.png",           "Comments"),
        7 => array("#",                      "rss_tag.png",          "Sponsors"),
        8 => array("#",                      "fileview_preview.png", "Video"),
        9 => array("information.php",        "help_about.png",       "Information")
    );
    
    function hiddenmenu($iconIds) {
        global $choices;
    
        foreach ($iconIds as $iconId){
            echo '<div class="icon-no-spacer">'
               . '<p><a id="' . $iconId . '"'
               . ' href="' . $choices[$iconId][0] . '"'
               . ' title=""><img src="images/icons/48/' . $choices[$iconId][1] . '"'
               . ' alt="" />' . $choices[$iconId][2] . '</a></p>' ."\n";
        }
    }
    
    hiddenmenu(array(1,2,3,8,9));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.