tektipsismyfavorite
Technical User
I'm having the hardest time trying to do a "page view style switch" where the user can view a page 1 of 2 ways. Basically, if there is no "view" variable set in the URL, then the view is "normal", but if $_GET['view] == "list", then it's list view. The problem is switching them back and forth from normal to list. If I try extracting "view=list" from $_SERVER['QUERY_STRING'], it leaves the trailing question mark on the URL if there's nothing else left in the server string.
Basically what I'm trying to do is:
if(URL has "view=list" in it){
if(QUERYSTRING has other stuff in it){
file.php?(otherstuff -[minus] 'view=list');
} else{
file.php;
}
} else {
if(QUERYSTRING has other stuff in it){
file.php?otherstuff&view=list;
} else{
file.php?view=list
}
}
I'm just not sure how to keep my URL clean from extra '&'s and extra '?'s.
Basically what I'm trying to do is:
if(URL has "view=list" in it){
if(QUERYSTRING has other stuff in it){
file.php?(otherstuff -[minus] 'view=list');
} else{
file.php;
}
} else {
if(QUERYSTRING has other stuff in it){
file.php?otherstuff&view=list;
} else{
file.php?view=list
}
}
I'm just not sure how to keep my URL clean from extra '&'s and extra '?'s.