Re: Help retrieving an HTML array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mauricio Pellegrini wrote:
Hi ,
 I have a HTML page with a form in which there are some inputs like
these:

	input type=text  name=xname value="3303"
	input type=text  name=xname value="9854"
	....
	input type=text  name=xname value="n..."


the name of the input is always the same ( xname )

This generates automatically generates an array named xname in HTML with all the diferent values assigned to a diferent position.

that sentence is:

a, borked
b, incorrect


the following is in no way legal HTML:

'input type=text  name=xname value="n..."'

assuming xHTML it should be:
<input type="text" name="xname" value="n..." />


but that doesn't get you what you want, the name of the
inputs should be 'xname[]' not 'xname' - when the name of each input
is 'xname' php will read in each value overwriting the previous one...
so $_POST['xname'] will contain the value of last 'xname' input in
the page. so:

<input type="text" name="xname[]" value="n..." />

			      ^^----- these are the important chars!


My question is :

How do I retrieve that array from within PHP ?


I've tryed the following

	$xname=$_REQUEST['xname'];

and then
	echo $xname[0][0] ; // this returns nothing
echo $xname[0] ; // this returns only first digit of the first input
None of the above seem to recognize that xname is ( in HTML ) an array .

Any help greatly appreciated

Thanks
Mauricio







On Sun, 2005-10-02 at 19:38, adriano ghezzi wrote:

if i understand well you need to get an array from html post


if you use the same name for your html fields you automatically have
an array in $_POST

eg

input type=text  name=myfield value="field_1"
input type=text name=myfield value="field_2"

you'll get the array  ar_myfield = $_POS['myfield']

you should achieve the same result using myfield[key] in the name of html

hyh

by ag.


2005/10/2, Martin van den Berg <martinvdberg@xxxxxxxxx>:

Newbe question:

How does one convert an array into a HTML GET request easely? Are
there any standard functions?

Same for HTML POST requests.

Thanks,

Martin.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux