[thelist] Multiple form entries in PHP...

Allie Micka allie at pajunas.com
Fri Nov 30 09:47:26 CST 2001


> A quick question about php forms.
> When submiting multiple entries for one field.
> 
> eg. ?field=1&field=2&field=3
> 
> what does PHP do with all the values? All I can get is the last one?
> Even a count() says it's only got 1 thing in it!

You appear to be using the GET method, perhaps POST is in order.  

One of php's coolest features is its ability to handle form fields as
arrays.  

name your fields with a [], such as field1[], and it will return an
array with one or more elements.  Look at
http://www.php.net/manual/en/language.variables.external.php  and try it
out.

Note that this can also be handy to separate different sections of the
form as well:

address[street][]
address[street][]
address[city]
address[state]
...

and don't forget to use print_r to see what you got back!

Thanks,

Allie Micka
 pajunas interactive, inc.
 web hosting and reusable components
 http://pajunas.com





More information about the thelist mailing list