Jump to content

$_GET an array?


michaellunsford

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.
Link to comment
https://forums.phpfreaks.com/topic/7665-_get-an-array/
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.
Link to comment
https://forums.phpfreaks.com/topic/7665-_get-an-array/#findComment-28008
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.
Link to comment
https://forums.phpfreaks.com/topic/7665-_get-an-array/#findComment-28012
Share on other sites

Archived

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

×
×
  • 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.