Jump to content

Recommended Posts

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 $_GET
print "$var=$val&amp;"; }
/*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 &amp;hide=
echo '?'.$_SERVER['QUERY_STRING'].'&amp;hide=side'; }
else { // if there isn't, make a query string

echo '?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]
Link to comment
https://forums.phpfreaks.com/topic/30412-solved-deleting-part-of-a-query-string/
Share on other sites

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.