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