To write a link that only changes the query string, just use
<a href="?foo=bar">whatever</a>
So, if you are in http://the/current/url.php
, he goes to http://the/current/url.php?foo=bar
, or if you http://somewhere/else?entire=ly
, he goes to http://somewhere/else?foo=bar
.
a source
to share