Having a problem here....
I can't seem to find a good way to 'add' and 'subtract' $variables to an URL string....
Here is my example:
in the url I have http://mywebsite.com/index.php?y=2011
For source code I have:
$currentPage = $_SERVER['PHP_SELF'];
Then if I want to add different $variables to the url string, I have been trying this...:
echo '<a href="$currentPage.&t=col">College</a>';
But it isn't keeping the value of the current URL.. .?
It displays : http://mywebsite.com/index.php?&t=col
Instead of : http://mywebsite.com/index.php?y=2011&t=col (doesn't keep the $y variable)
I also need to find a way to change the $y and $t variable by any links, so I can easily change it to 2010, or 2009, with keeping the current $t variable.. ???
Thanks in advance!
HERE IS What I came up with from the great help!!!
$url = "http://www.mywebsite/index.php?";
foreach($_GET as $key=>$val){
$url.="$key=$val&"; }
echo '<a href="' . htmlspecialchars($url . 't=col') . '">College</a>';