Jump to content

How to Send Mutiple $_Gets ???


icoppa

Recommended Posts

Hello All, I'm having trouble figuring this one out.

I have a page that does a standard query to a MySQL database. (This works fine)

Then I have some <if's> that change the query based on $_GETS

if($_GET[view] == "resolved") {$mylink = $_SERVER[php_SELF];} else { $mylink = $_SERVER[php_SELF]."?view=resolved"; }

if($_GET[expand] == "yes") {$mylink2 = $_SERVER[php_SELF];} else { $mylink2 = $_SERVER[php_SELF]."?expand=yes"; }

These <if's> work fine. =)

I have links on the page that will set the $_GET to view=resolved or expand=yes.

 

My Problem:

How to get the page to remember my first selection?

I click the index.php?view=resolved link and I get just that.

I click the index.php?expand=yes link and I get that BUT loose the view=resolved

 

I need the page to remember my first selection so I get somthing like this - index.php?view=resolved&expand=yes

 

Any Tips,Tricks or Critiques Welcome

Thank you for your time!

Link to comment
Share on other sites

You just want to pass the entire query string on to the next page?

<?php
// if the page was http://www.example.com/index.php?view=resolved&expand=yes
// $_SERVER[QUERY_STRING] = view=resolved&expand=yes
$mylink = $_SERVER[php_SELF] . '?' . $_SERVER[QUERY_STRING];
?>

Link to comment
Share on other sites

I'm assuming that there will be times that other variables will be part of the $_GET array which you DON'T want to pass on.  When that is the case, you won't want to use the above code.

 

Try this on for size.

if($_GET[view] == "resolved") {
  $mylink = $_SERVER[php_SELF];
  if(is_set($_GET['expand'])){$mylink .= "?expand=" . $_GET['expand'];} 
} else { 
  $mylink = $_SERVER[php_SELF]."?view=resolved";
  if(is_set($_GET['expand'])){$mylink .= "&expand=" . $_GET['expand'];} 
}
if($_GET[expand] == "yes") {
  $mylink2 = $_SERVER[php_SELF];
  if(is_set($_GET['resolved'])){$mylink .= "?resolved=" . $_GET['resolved'];}
} else { 
  $mylink2 = $_SERVER[php_SELF]."?expand=yes"; 
  if(is_set($_GET['resolved'])){$mylink .= "&resolved=" . $_GET['resolved'];}
}

Link to comment
Share on other sites

You're supposed to type it like:

$_SERVER['PHP_SELF']

not

$_SERVER[php_SELF]

As for remembering the values, just use sessions.

You're absolutely right, that's what I get for typing it before I shutdown and go home. sorry about that.

Link to comment
Share on other sites

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.