Jump to content


Photo

$_GET an array?


  • Please log in to reply
2 replies to this topic

#1 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 18 April 2006 - 01:14 AM

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:

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

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.

#2 KrisNz

KrisNz
  • Members
  • PipPipPip
  • Advanced Member
  • 271 posts
  • LocationAuckland, New Zealand

Posted 18 April 2006 - 02:39 AM

[!--quoteo(post=365798:date=Apr 18 2006, 11:14 AM:name=michaellunsford)--][div class=\'quotetop\']QUOTE(michaellunsford @ Apr 18 2006, 11:14 AM) View Post[/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:

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

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.

#3 michaellunsford

michaellunsford
  • Members
  • PipPipPip
  • Advanced Member
  • 1,023 posts
  • LocationLouisiana, USA

Posted 18 April 2006 - 02:47 AM

I am trying to pass an unknown number of variables to PHP to use in a mysql query.

simplified example:

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

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users