mlacy03 Posted December 12, 2006 Share Posted December 12, 2006 I have code on my site that hides or shows a table based on what is passed to it through GET. I haven't been able to completely work out the link to hide and show the table. The query works, but I cannot get the link to update itself when more than one other variable is passed through GET at the same time:This is what I have now:[code]<?php if ($_GET[hide]==="side") { // if it's supposed to be hidden, show link to show the <td>?> <td align="center"><a href="<?php echo $_SERVER['PHP_SELF'].'?'; /* This is where I am having the most problems */while (list($var, $val) = each($_GET)) { // I need to get rid of the [hide] variable in $_GETprint "$var=$val&"; } /*Everything below seems to work */?> "><img src="core.402/img/max.PNG" width="11" height="11" border="0" alt="Maximize" /></a></td><?php } else { // Because if $_GET[hide] is not defined, it'll do the else, right??><td><div><a href="<?php echo $_SERVER['PATH_TRANSLATED']; if ($_SERVER['QUERY_STRING'] != ""){ //if there is a query string, add it on the end as &hide= echo '?'.$_SERVER['QUERY_STRING'].'&hide=side'; } else { // if there isn't, make a query stringecho '?hide=side'; } ?> "><img src="core.402/img/min.PNG" width="11" height="11" border="0" alt="Minimize" /></a><!-- links go here --> </div></td><?php } ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30412-solved-deleting-part-of-a-query-string/ Share on other sites More sharing options...
alpine Posted December 12, 2006 Share Posted December 12, 2006 [quote]I need to get rid of the [hide] variable in $_GET[/quote]Are you asking something like this?[code]<?php$_GET['whatever'];// use it$_GET['whatever'] = false;// cannot use it anymore?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30412-solved-deleting-part-of-a-query-string/#findComment-139965 Share on other sites More sharing options...
mlacy03 Posted December 12, 2006 Author Share Posted December 12, 2006 when [hide] is set, the <td> only shows a link to the original page. I have 2-3 variables being passed on some pages, so i need a way to get rid of the last one, [hide] so the user can see the menu again. It's a bit like the code for the left nav on the phpfreaks homepage (with the [close_left] and the [open_left]), except I'm using a small image instead of a text link. Quote Link to comment https://forums.phpfreaks.com/topic/30412-solved-deleting-part-of-a-query-string/#findComment-139973 Share on other sites More sharing options...
alpine Posted December 13, 2006 Share Posted December 13, 2006 [code]<?phpwhile (list($var, $val) = each($_GET)){if($var != "hide"){ print "$var=$val&";}}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30412-solved-deleting-part-of-a-query-string/#findComment-140218 Share on other sites More sharing options...
mlacy03 Posted December 13, 2006 Author Share Posted December 13, 2006 Thanks! This helps out a lot. Quote Link to comment https://forums.phpfreaks.com/topic/30412-solved-deleting-part-of-a-query-string/#findComment-140642 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.