The real code isn't wrong, the example I posted is different from what I really have, it looks more like
if ($_GET['order'] == "ASC") $order = "DESC";
else $order = "ASC";
so if the order is DESC or there's no order at all, it is going to be ASC, else order = DESC.
Anyway, that's not the problem, the problem is with the query string, I want to be able to add a variable that doesnt exist to it, for example if I have
?order=NAME&sort=ASC
I want to be able to add a non-existing variable, such as 'page'
?order=NAME&sort=ASC&page=2
BUT if a variable already exists in the query string, I want to update the value
lets say I press a link to browse through page 3, and the current query string is
?order=NAME&sort=ASC&page=2
I want the new query string to only update the page value, like this
?order=NAME&sort=ASC&page=3
insted, I get this
?order=NAME&sort=ASC&page=2&page=3
so if I keep browsing through all the pages, I get like
?order=NAME&sort=ASC&page=2&page=3&page=4
?order=NAME&sort=ASC&page=2&page=3&page=4&page=5
?order=NAME&sort=ASC&page=2&page=3&page=4&page=5&page=6
it works, I get to see page 5, 6, 7, etc., but I'll end up with a 324938492 characters query string this way.
imagine if I keep sorting the list in a different way, I'd get something like
?order=NAME&sort=ASC&page=2&page=3&page=4&page=5&page=6&order=DATE&sort=ASC
and if I keep clicking
?order=NAME&sort=ASC&page=2&page=3&page=4&page=5&page=6&order=DATE&sort=ASC&order=DATE&sort=DESC
get it now? I end up with a really big string, I want to only UPDATE the current query variables, instead of adding em to the end of the string if they already exist.
Bleh I hope I made my point this time, thanks again for any help.