Jump to content

React to two variables?


Davo

Recommended Posts

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!

 

Link to comment
Share on other sites

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?)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.