Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change $HTTP_GET_VARS without changing others

Status
Not open for further replies.

whodaman

Programmer
May 23, 2001
60
CA
I would like to go to the same url ex:
Code:
index.php?name=Models&orderby=tempOrder&sub=mysub&othersub=myOtherSub

but simply change one of the variables such as
Code:
orderby=myModel
without knowing/changing the other variables.

Is there a way I can define
Code:
$HTTP_GET_VARS['orderby']=myModel;
and refresh the page?

Thanks
 
Sure, you can do that.

Change the variable in $_GET (preferred over $HTTP_GET_VARS if you're running PHP version 4.1.0 or newer).

Loop through $_GET to create a new URL string.

Use
header ("Location: <yourURLstring>");
to redirect the browser.

But I don't know why you don't just put the same logic inside the same first script to which the form submits.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I might be missing something, but how do i loop though the $_GET URL string if I don't know/don't care what it is?
 
$_GET is just an associative array with a special scope. You can loop through an associative using foreach:

for ($_GET as $key => $value)
{
//do some stuff
}


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top