Jump to content

Passing variable to address bar


Davo

Recommended Posts

Hello all.

 

I am working on a website that is having a language translation added. (As an after thought.)

I thought I could do this by passing a variable through the address bar. (eg. www.example.com/welcome.php?id=Chinese )

However some of the link buttons are already effected by a variable. (contact page contains a variable (request = contact) that turns the contact button red.) Is there any way that I could  make this button respond to two variables? (request = contact and id = Chinese) Therefore allowing the button to still turn red but also adding the variable to the link when appropriate?

 

Something like this??

 

If ($Request =='Contact')

{

$ContactImage="<a href=\"Contact.php\"><img src='Images/NavContactRed.gif' border='0'></a>"; 

}

elseif($Request =='Contact' AND $id == 'Chinese')

{

$ContactImage="<a href=\"Contact.php?id=Chinese\"><img src='Images/NavContactRed.gif' border='0'></a>";

}

 

Thanks

Link to comment
Share on other sites

separate each item with &

 

e.g

<a href="www.example.com/welcome.php?id=Chinese&anotherarg=somethingelse">Text</a>

 

I've never heard of putting &...you only have to put the & to separate the variables.

 

<a href="www.example.com/welcome.php?id=Chinese&anotherarg=somethingelse">Text</a>

 

You may be able to do it both ways...I'm not sure.

Link to comment
Share on other sites

Hey KrisNz

 

Thanks for that. I only want to pass one variable through the address bar as the other variable is 'embedded' - eg. Contact page has <? $Request='Contact'; ?> at the top. This makes the contact button red when clicked. However I now want to add (?id=Chinese) to that buttons link if the user chooses the Chinese translation.

So the user chooses Chinese translation and all page links will have id=Chinese added to them.

I want the contact button to react to both variables - firstly turn red because the contact button has been clicked and secondly pass the information that the user selected Chinese as their language. Is this possible?!

Link to comment
Share on other sites

Hey everyone

 

Thanks for your replies - is it possible to do something like this? (Have two variables determine how the button would act.)

 

if($a =='Contact' AND $b == 'variable2')

{

$button="<a href=\"Contact.php?id=variable2\"><img src='Images/NavProjectsRed.gif' border='0'></a>";

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.