Re: Retrieving the multiple values set by a form
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Thu, 28 Sep 2006 07:56:49 -0400
Ron Barnett wrote:
"Girish" <girishbhat6620@xxxxxxxxx> wrote in message news:1159359055.574104.168360@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi Everyone,
I am passing a form to a php script for further processing.
I am able to retrieve the last value set for that given form variable
using
$variable=$_REQUEST['form_variable'];
My question is, what is the Php way of retrieving all the values passed
for the same form variable?
For example, if the php script is called with a syntax like
http://xxxx/get_variables.php?form_variable=value1&form_variable=value2&form_variable=variable
, how do I iterate through all the values that form_variable has been
set to?
Thanks and regards,
Girish
Hi Girish,
In the example you have given, which equates to a Get, the variables will indeed overwrite each other with only the last value surviving, as stated by lorento.
You can however create an array by suffixing the variable name (in the HTML form) this
<input name='inp[0]' type='hidden' value='first value'>
<input name='inp[1]' type='hidden' value='second value'>
<input name='inp[2]' type='hidden' value='third value'>
once this is received by your PHP script the values may be retrieved :
$myArray = $_REQUEST('ip'); // note no subscripts required
$myArray['0'] will contain 'first value', $myArray['1'] the second value, and so on
BTW Register globals should be OFF on any production machine so there is little point in having it on in a development machine.
HTH
Ron
Actually, it's even easier than that. No need to specify the index when you're using the default.
<input name='inp[]' type='hidden' value='first value'>
<input name='inp[]' type='hidden' value='second value'>
<input name='inp[]' type='hidden' value='third value'>
inp[0] == 'first value'
inp[1] == 'second value'
inp[2] == 'third value'
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- References:
- Retrieving the multiple values set by a form
- From: Girish
- Re: Retrieving the multiple values set by a form
- From: Ron Barnett
- Retrieving the multiple values set by a form
- Prev by Date: Re: Where does php session cookies stored
- Next by Date: Re: Retrieving the multiple values set by a form
- Previous by thread: Re: Retrieving the multiple values set by a form
- Next by thread: XP Development Environment
- Index(es):
Relevant Pages
|