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….
First, create the CSS for the selected item:
Then create a simple PHP function to do your highlighting:
Place that function in each
<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:
Then create your current nav function:
And on each list:
So your whole list would be: