Hi, i have just finished coding a design into html / css. I have spit the code up into php includes for the HEADER, NAVIGATION and the FOOTER
I have coded my navigation so that when a tab (page) is selected from navigation it has a different style. I have declared this style in the css called .selected
Can someone help me write a simple IF statement, that will work like this:
IF the current page is 'contact.php' echo '.selected' ELSE do nothing
I was hoping to past this IF statement into the code for each tab / button so it would use the .selected class if it was on that page, thanks in advance for your help...
If the ELSE is doing nothing, you don't need to include the ELSE portion.
switch( $_SERVER['REQUEST_URI'] )
case '/about.html' : $selected = 'ff0'; break;
case '/blog.html' : $selected = '0ff'; break;
case '/contact.html' : $selected = 'f0f'; break;
case '/terms.html' : $selected = 'f00'; break;
case '/subscribe.html' : $selected = '090'; break;
default : $selected = '000';
$selected = 'style="background-color:#' .$selected .'"';
<div <?php echo isset($selected) ? $selected : NULL;?> >
Beware: All Apache Versions are not the same. If on the off-chance $SERVER['REQUESTURI'] does not return the value expected then try this script:
print_r( $_SERVER );
Cool, thanks all for your help...
This topic is now closed. New replies are no longer allowed.