468,248 Members | 1,459 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,248 developers. It's quick & easy.

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 ("selectedFacStaff.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!!!!!
Oct 27 '06 #1
1 2466
raji20
28
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]
Oct 27 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by John | last post: by
13 posts views Thread by Richard | last post: by
8 posts views Thread by gil | last post: by
4 posts views Thread by JoJo | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.