Jump to content

Archived

This topic is now archived and is closed to further replies.

michaellunsford

$_GET an array?

Recommended Posts

I saw something about this somewhere, but I can't find it. Maybe I'm imagining things?

I have a set of variables I'd like to use in a while(next($array)) loop. I'd like to pass that array using the GET method. What I remember seeing was naming form fields like an array, for example:

[code]<input type="text" name="field[1]">[/code]

would result in PHP associating it as an array when received. But, how to access that array is escaping me. I guess I could strpos(current($_GET),"[") and recreate the arrays? This seems like the long way around though.

thanks for any direction.

Share this post


Link to post
Share on other sites
[!--quoteo(post=365798:date=Apr 18 2006, 11:14 AM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Apr 18 2006, 11:14 AM) [snapback]365798[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I saw something about this somewhere, but I can't find it. Maybe I'm imagining things?

I have a set of variables I'd like to use in a while(next($array)) loop. I'd like to pass that array using the GET method. What I remember seeing was naming form fields like an array, for example:

[code]<input type="text" name="field[1]">[/code]

would result in PHP associating it as an array when received. But, how to access that array is escaping me. I guess I could strpos(current($_GET),"[") and recreate the arrays? This seems like the long way around though.

thanks for any direction.
[/quote]

If your talking about a variable you want to recreate across server requests then you need to look into serialization. The code you've shown is for form controls such as multiple select enabled listboxes or a series of checkboxes.

Share this post


Link to post
Share on other sites
I am trying to pass an unknown number of variables to PHP to use in a mysql query.

simplified example:

[code]
$query="select * from table where ";
do {
    $query.=key($_GET)."='".current($_GET)."' AND ";
}while(next($_GET['variable']));
$query.="1";
$result=mysql_query($query);
[/code]

rest assured that all is properly secured and from trusted sources.

Share this post


Link to post
Share on other sites

×

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.