Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Posts
    152
    Thanks
    5
    Thanked 0 Times in 0 Posts

    PHP include to highlight active page

    Hi,

    I am using this code in a PHP include to high light the active page but it doesn't work. Any ideas what's wrong here?

    Code:
    <li id="nav11">
          <a <?php if ($_SERVER['REQUEST_URI']=="/contact.php") echo " class=\"actv\""; ?> href="contact">Contact</a>
        </li>

    many thanks
    Andy

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,436
    Thanks
    23
    Thanked 629 Times in 628 Posts
    The fact that you have <li id="nav11"> before and </li> after without the echo statement tells me your in html BUT you are looking for a php URL =="/contact.php")

    Something wrong there.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,339
    Thanks
    11
    Thanked 288 Times in 287 Posts
    Sunfighter, I have no idea what you're referring to. Most php scripts have html in them and have a suffix ".php" - that's pretty normal stuff.

    Andy, you've given us very little to go on. Have you eliminated the final html as the problem, that's why you're not showing it? If you haven't, can you at least show it to us (via a link) so we can see the bigger picture here?

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,436
    Thanks
    23
    Thanked 629 Times in 628 Posts
    Sunfighter, I have no idea what you're referring to.
    A shame that is. I was diskabobbled when I wrote that. Your correct, some php files contain straight html and an occasional php section instead of being written in full bore php.

    @ neodjandre
    At the beginging of your script write this:
    <?php
    echo $_SERVER['REQUEST_URI'];
    die;
    ?> and see what it returns. Normally I get the name of the file and the folder it's in. That maybe the problem.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

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