/    Sign up×
Community /Pin to ProfileBookmark

Simple IF Statement To Call Class

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…

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@Dragonfire2008Apr 03.2012 — I think you want JavaScript...
Copy linkTweet thisAlerts:
@NogDogApr 03.2012 — [code=php]
<p class='some classes <?php echo (basename($_SERVER["SCRIPT_NAME"]) == 'contact.php') ? ' .selected' : ''; ?>'>foo</p>
[/code]
Copy linkTweet thisAlerts:
@oo7mlauthorApr 04.2012 — Cool, thanks for that NogDog
×

Success!

Help @oo7ml spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...