constant Mouseover if page is being viewed

Discussion in 'PHP' started by Silver89, Nov 13, 2006.

  1. #1
    Ok, i have a site funzac.com/sitec which is for a school project.

    I need the links at the top to have the css mouseover applied if it is on that current page.

    To do this i figured i would need to get the url with php and then have something in the link style to tell it if 1 do and if 0 display normal.

    this is as far as i got before i completly mind blanked

    <?php
    $url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    ?>
    <div class="header">
    <a href="index.php"><img class="image" src="images/homepage.png" width="500" height="80"/></a>
    <div class="navigation">
    
    <a style="<? if{$url == href ?>" href="index.php">Home</a>
    <a href="about.php">About</a>
    <a href="contact.php">Contact</a>
    <a href="hours.php">Hours</a>
    <a href="location.php">Location</a>
    <a href="services.php">Services</a>
    
    </div>
    </div>
    Code (markup):
     
    Silver89, Nov 13, 2006 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $php_self will output the file name so you would use

    if($php_self=="index.php"){
    // do something
    }
    PHP:
     
    mad4, Nov 13, 2006 IP
  3. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #3
    This is what i now have:

    <a style="<? if($php_self=="./"){echo"border-bottom: 3px solid #FFFFFF;color: #FFFFFF;";}?>" href="index.php">Home</a>
    Code (markup):
    It only works if i put else and then put the same code but then it doesnt turn off.

    SO basically the =="./" is wrong. I need it to be if php_self = current page i think.
     
    Silver89, Nov 13, 2006 IP
  4. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #4
    done with the following

     
    Silver89, Nov 13, 2006 IP