Davo Posted March 10, 2008 Share Posted March 10, 2008 Hello All! Is it possible to get a part of my website (A button for instance) to react to two variables at the same time? Lets say I have a variable on my page that tells my navigation bar that I have the 'contact' page open (like this <? $Request='Contact'; ?>) This variable turns my 'contact button' grey (indicating I'm on that page.) I would now like to add another variable that will change the language. (This variable would be passed through the address bar) So the result would be that my 'contact button' would be grey and say 'contact' in the language of choice. Something like: if($Request=='Contact') { $ContactImage="<a href=\"Contact.php\"><img src='Images/NavContactRed.gif' border='0'></a>"; } elseif($Request=='Contact' AND 'French') { $ContactImage="<a href=\"FRENCHContact.php\"><img src='Images/NavContactRed.gif' border='0'></a>"; } Thanks! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 10, 2008 Share Posted March 10, 2008 You want to do: <?php elseif($Request=='Contact' || $Request == 'French') // $Request can't be both 'Contact' and 'French' at the same time ?> Ken Quote Link to comment Share on other sites More sharing options...
Davo Posted March 17, 2008 Author Share Posted March 17, 2008 Thanks kenrbnsn I have had some time to tinker and managed to get it to work! I gave the second variable a new name and after a bit of guess work it did the job. Example: if ($Request == 'Contact' and $id == 'CN') { $ContactImage="<a href=\"Contact.php?id=CN\"><img src='Images/CNNavContactRed.gif' border='0'>"; I now have one button that can react to two variables. hope that makes sense to anyone else trying to do the same thing! (is there a way to show that this problem has been solved on the forum list?) Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 17, 2008 Share Posted March 17, 2008 You really should use the "&&" operator instead of "and" in the if statement: <?php if ($Request == 'Contact' && $id == 'CN') { $ContactImage='<a href="Contact.php?id=CN"><img src="Images/CNNavContactRed.gif" border="0">'; ?> Ken Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.