Results 1 to 4 of 4

Thread: Simple IF Statement To Call Class

Hybrid View

  1. #1
    Join Date
    Jul 2006

    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...

  2. #2
    Join Date
    Dec 2011
    I think you want JavaScript...

  3. #3
    Join Date
    Aug 2004
    PHP Code:
    <p class='some classes <?php echo (basename($_SERVER["SCRIPT_NAME"]) == 'contact.php') ? ' .selected' ''?>'>foo</p>
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  4. #4
    Join Date
    Jul 2006
    Cool, thanks for that NogDog

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center