Hi everyone
I have a menu that I'm creating dynamically with links that have query strings on the end of them. Basically I want the menu item, that's related to the page the user is on, to be in a different colour to the rest of the menu items.
An example of the links for the menu items follows:
fruit.php?type=1
fruit.php?type=2
fruit.php?type=3
fruit.php?type=4
fruit.php?type=5
Now using basename($_SERVER["REQUEST_URI"]) in an if statement makes all the menu items the colour that I want the menu item related to the current page to be.
I know that this is happening because all links are linking to fruit.php. Is there any way around this so that the specified query string is included in order to have one menu item a different colour instead of all of them?
Example of the if statement:
$toc = array("fruit.php?type=1" => "Apples", "fruit.php?type=2" => "Bananas", "fruit.php?type=3" => "Oranges", "fruit.php?type=4" => "Watermelons", "fruit.php?type=5" => "Pineapples");
foreach($toc as $item => $key){
if(basename($_SERVER["SCRIPT_NAME"]) == $item){
echo "<li><a class=\"currentNavSub\" href=\"".$item."\">".$key."</a></li>";
}else{
echo "<li><a href=\"".$item."\">".$key."</a></li>";
}
}
I hope I've made some sense in this.