[thelist] beginner PHP question
Garrett Coakley
garrett at polytechnic.co.uk
Sat Feb 16 11:43:00 CST 2002
On Sat, 16 Feb 2002 12:12:16 -0500 "Nicole Parrot" <nicole at parrot.ca>
wrote:
> Aren't the entries from a form available to me as an array so that I
> can loop through them? It would save me loads of coding, but all the
> tutorials Im seeing are too simple to need that.
You can access data from a form in the $HTTP_POST_VARS or $HTTP_GET_VARS
(or $_POST and $_GET in php 4.1) variables.
You can also name all your form elements with a [] on the end, and then
php will construct an array on the fly when the form is submitted. ie:
<input type="text" name="form[]" />
<input type="text" name="form[]" />
and then in your php code, something like
$num = count($form);
for ($i = 0 ; $i < $num ; $i++) {
//do something with each element
}
(although there's something to be said for not putting []'s in the name
attribute, as they're not allowed according to the HTML spec)
Lots more info on this in the annotated php manual:
http://www.php.net/manual/en/language.variables.external.php
--
-----------------------------------------------------------------------
WORK: http://spiked.co.uk/
PLAY: http://polytechnic.co.uk/
More information about the thelist
mailing list