Davo Posted January 18, 2008 Share Posted January 18, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/86580-passing-variable-to-address-bar/ Share on other sites More sharing options...
KrisNz Posted January 18, 2008 Share Posted January 18, 2008 separate each item with & e.g <a href="www.example.com/welcome.php?id=Chinese&anotherarg=somethingelse">Text</a> Quote Link to comment https://forums.phpfreaks.com/topic/86580-passing-variable-to-address-bar/#findComment-442378 Share on other sites More sharing options...
pocobueno1388 Posted January 18, 2008 Share Posted January 18, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/86580-passing-variable-to-address-bar/#findComment-442397 Share on other sites More sharing options...
Davo Posted January 18, 2008 Author Share Posted January 18, 2008 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?! Quote Link to comment https://forums.phpfreaks.com/topic/86580-passing-variable-to-address-bar/#findComment-442402 Share on other sites More sharing options...
teng84 Posted January 18, 2008 Share Posted January 18, 2008 I've never heard of putting &...you only have to put the & to separate the variables. & is entity name of & Quote Link to comment https://forums.phpfreaks.com/topic/86580-passing-variable-to-address-bar/#findComment-442405 Share on other sites More sharing options...
pocobueno1388 Posted January 18, 2008 Share Posted January 18, 2008 I've never heard of putting &...you only have to put the & to separate the variables. & is entity name of & Oh duh! I should have known that, hah. Well, why not just take the shortcut and only write & instead of the entity? ;P Quote Link to comment https://forums.phpfreaks.com/topic/86580-passing-variable-to-address-bar/#findComment-442407 Share on other sites More sharing options...
KrisNz Posted January 18, 2008 Share Posted January 18, 2008 try putting ©=1 and see what happens! & is the html entity for & and the correct way to put an ampersand in an html document, it wont validate if you don't. Quote Link to comment https://forums.phpfreaks.com/topic/86580-passing-variable-to-address-bar/#findComment-442408 Share on other sites More sharing options...
pocobueno1388 Posted January 18, 2008 Share Posted January 18, 2008 it wont validate if you don't In that case, it's understandable. I've never messed with HTML validation, so I'm not too knowledgeable with that. Quote Link to comment https://forums.phpfreaks.com/topic/86580-passing-variable-to-address-bar/#findComment-442411 Share on other sites More sharing options...
Davo Posted January 18, 2008 Author Share Posted January 18, 2008 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/86580-passing-variable-to-address-bar/#findComment-442432 Share on other sites More sharing options...
Davo Posted January 18, 2008 Author Share Posted January 18, 2008 or else could I do something like this: $ProcessImage="<a href=\"Process.php<? echo $MY_VARIABLE ?>\"><img src='Images/NavProcessWhite.gif' border='0'></a>"; Have an echo within a line like that?! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/86580-passing-variable-to-address-bar/#findComment-442437 Share on other sites More sharing options...
Davo Posted January 22, 2008 Author Share Posted January 22, 2008 *Bump* Quote Link to comment https://forums.phpfreaks.com/topic/86580-passing-variable-to-address-bar/#findComment-445811 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.