Updating a GET variable
| From: | Marc Guay | Date: | Tue, 09 Nov 2010 20:12:31 +0000 |
| Subject: | Updating a GET variable | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-309414@lists.php.net to get a copy of this message | ||
Hi folks,
I'm sure this is an easy one that's standing right in front of me but
I'm too blind to see. I have a page with an URL like this:
index.php?name=value&this=that. I have a link on the bottom of the
page which allows the user to switch languages. I need to hang onto
the existing $name and $this get variables.
I tried
<a href='&lang=en'>Flip</a>
and it loses all previous GET data. Then I tried
<a href='<?php echo $_SERVER['SCRIPT_NAME'] ;?>?<?php echo
$_SERVER['QUERY_STRING']; ?>&lang=en'>Flip</a>
And it continually appends more &lang=en's to the URL if the user
keeps clicking on it (for whatever reason).
Now I've put it in a form and it works as expected, but the display
value and my under-the-hood value need to be different, so it's a
fail. What's the best way to update the value of a GET var?
Marc