PHP get directory and switch image (and css)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aimeein therough
    New Member
    • Oct 2006
    • 1

    PHP get directory and switch image (and css)

    Hi all, I am quite the PHP idiot. I know about includes and am trying to slowly learn more but I've got to figure this out fast (as usual). I have a drop-down menu that uses CSS, combined with top-level images. I would like to use PHP to check the current directory of the current page and, based on the directory, do two things: 1) determine which image to load for the menu and 2) change the background color of the drop-down menu beneath the image. So, for example, if we are in the directory "Faculty and Staff," then the image that loads for that the Faculty and Staff drop down menu is the white one ("selectedFacSt aff.gif") and the menu that appears when you hover over it has "background-color:white" rather than "background-color:#ffffcc". I would appreciate any gentle advice you can give me. I tried request_uri just to check it against the current directory, but don't know how to split the return to get just the directory (is there some way to use a wild card, like request_uri and check if it equals "facstaff/*")? thanks much!!!!!
  • raji20
    New Member
    • Aug 2006
    • 28

    #2
    This will give you the working directory, so you can use this, hope this is helpfull to you

    [php]
    $fetch = $_SERVER["PHP_SELF"];
    $expval = explode("/",$fetch);
    $fcnt = count($expval);
    $fval = $expval[$fcnt-2];
    $workingDir = $fval;
    [/php]

    Comment

    Working...