471,072 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,072 software developers and data experts.

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 2526
This will give you the working directory, so you can use this, hope this is helpfull to you

$fetch = $_SERVER["PHP_SELF"];
$expval = explode("/",$fetch);
$fcnt = count($expval);
$fval = $expval[$fcnt-2];
$workingDir = $fval;
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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.