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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:11:02+00:00 2026-06-08T00:11:02+00:00

i have this div for my menu bar, here what i want is: <div

  • 0

i have this div for my menu bar, here what i want is:

<div class="menu_nav" style="float:left; margin-bottom: 0px; padding:0px; font-family:verdana; font-size:16px;width: 100%; background-color: rgb(37,198,255);">
        <ul>
          <li> 
            <div class="menu1a">
              <a class="menu3a" href="<?=$HOME_DIR?>/index.php">
                 <span class="menu2a">Home</span>
              </a>
            </div>
      </li>
      <li>
        <div class="menu1">
          <a class="menu3" href="<?=$PUBLIC_DIR?>/about.php">
             <span class="menu2">About</span>
          </a>
        </div>
      </li>
      <li>
        <div class="menu1">
          <a class="menu3" href="<?=$PUBLIC_DIR?>/myaccount.php">
             <span class="menu2">MyAccount</span>
          </a>
        </div>
      </li>         



          <li style="color:black;font-family:verdana;font-size:13px;float:right;padding-top:5px;">
               <?php
               if(isset($_SESSION['user']) && $_SESSION['user']!="")
                  {
                     echo "<div style='float:left;'>Hello, ".$_SESSION['name']."</div>  <div id='logout' style='float:left;margin-left:20px;' > 
                     Log Out</div>";
                   } 
               ?>
           </li>   
        </ul>
      </div>

i want to change the classes of the menu buttons according to the one which we are in the url:

i tried as follows:

<?php
$url=$_SERVER['REQUEST_URI'];
echo "$url";
if($url=="/signed/public/about.php")
{

}
else if($url="/signed/public/myaccount.php"){

}
else
?>

but i dont know how to change the classes of them, i.e., if i’m in the about.php page the about button should be highlighted i.e., that button should get the classes menu1a, menu2a, menu3a to them similarly when i’m in myaccount.php this button should get those classes. else the home button should be highlighted…

please guide me in writing the php code for this asap…thanks in advance….

  • 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-06-08T00:11:03+00:00Added an answer on June 8, 2026 at 12:11 am

    First, create the CSS for the selected item:

    .selected{background:orange;}
    

    Then create a simple PHP function to do your highlighting:

    function currentNav($url){
     if($_SERVER['REQUEST_URI']==$url){
      return 'selected';
     }
    }
    

    Place that function in each <li>:

      <li>
        <div class="menu1">
          <a class="menu3" href="<?=$PUBLIC_DIR?>/myaccount.php">
             <span class="menu2 <?=currentNav('/signed/public/about.php')?>">MyAccount</span>
          </a>
        </div>
      </li> 
    

    You can modify it. But you get the point.


    Update: To use your existing way of doing things…

    First create an array of your urls:

     <?php
     $urls=array(
       'home'    => '/signed/public/index.php',
       'about'   => '/signed/public/about.php',
       'account' => '/signed/public/myaccount.php'
     );
    

    Then create your current nav function:

    <?php
    function cn($url){
     global $urls;
      return ($_SERVER['REQUEST_URI']==$urls[$url])?'a':'';
    }
    ?>
    

    And on each list:

      <li>
        <div class="menu1<?=cn('about')?>">
          <a class="menu3<?=cn('about')?>" href="<?=$PUBLIC_DIR?>/myaccount.php">
             <span class="menu2<?=cn('about')?>">MyAccount</span>
          </a>
        </div>
      </li> 
    

    So your whole list would be:

        <ul>
          <li> 
            <div class="menu1<?=cn('home')?>">
              <a class="menu3<?=cn('home')?>" href="<?=$HOME_DIR?>/index.php">
                 <span class="menu2<?=cn('home')?>">Home</span>
              </a>
            </div>
      </li>
      <li>
        <div class="menu1<?=cn('about')?>">
          <a class="menu3<?=cn('about')?>" href="<?=$PUBLIC_DIR?>/about.php">
             <span class="menu2<?=cn('about')?>">About</span>
          </a>
        </div>
      </li>
      <li>
        <div class="menu1<?=cn('account')?>">
          <a class="menu3<?=cn('account')?>" href="<?=$PUBLIC_DIR?>/myaccount.php">
             <span class="menu2<?=cn('account')?>">MyAccount</span>
          </a>
        </div>
      </li> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this div in my code: <div id=advice class=validation-advice style=>some text here</div> Now,
I have this html structure <div class=top_menu> <ul> <li class=left><a href= class=family-filter>asdas</a></li> <li class=welcome>Welcome
So I have this code here: <table> <tr> <td width=200px valign=top> <div class=left_menu> <div
Assuming I have this HTML structure: <ul class='menu'> <li> <div></div> <div> <div></div> <div> <a
I have a menu set up this way: <div id='top-navigation'> <ul> <li><a class='top-nav-button-unclicked' href='#'>SUBJECT</a></li>
I have a menu bar that I want to control the visibility of DIV's
I have a wordpress menu like this one: <div id=top_menu> <ul class=menu> <li id=menu-item-1
I have the following jquery script: $(function(){ $('#top-menu').on('click', 'a.change-menu', function(e){ e.preventDefault() $(#menu-change-div).load($(this).attr(href)); }); });
I have this div structure <div class=panel> <div class=north></div> <div class=center></div> </div> The outer
I have this div inside a repeater, where i set the class, onmouseover and

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.