I have a form in which the user can add more textboxes as need be.
Ing1
Ing2
Ing3
....
There could be 1 input or there could be 30...
How can I, in php, determine the number of input controls so that I
can then loop through them one by one and process their data?
Thank you,
QB
If there is a better approach I would be interested.
QB
I myself go for displaying the max necessary and then checking each
for content when processing. Though it may put a big field of text
boxes on your form, but if the for is for data-entry savvy people
they'll appreciate not having to use extra controls to routinely add
something they need.
Use arrays. If your form elements look like this:
<input type="text" name="foo[]" />
Then they will be available as an array when you process it:
foreach($_SERVER['POST']['foo'] as $key => $value) {
//do something with each one
}
And you can easily know how many there are:
count($_SERVER['POST']['foo'])