Re: PHP Forms

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

 



R. Van Tassel wrote:
I am having an issue with a form, basically an order form, with 10 rows.
Each row is the same, the rows are being generated by a loop and I am
appending the counter of the loop to the name of the form elements (i.e.
quantity1, type1, next row = quantity2, type2, etc)

I can't seem to receive the variables without using sessions, which I'm
trying not to do. If only the first 2 rows are being filled out and
submitted I need to be able to loop through, grab all the variables and
print them out. Can anyone give any suggestion?

Make them an array:

<input type="text" name="quantity[1]" value="X">
<input type="text" name="quantity[2]" value="X">

etc etc.

Then when you post you get an array of quantities which you can loop through:

foreach($_POST['quantity'] as $p => $value) {
  if (empty($value)) continue; // they didn't fill this field in.
  ....
}

--
Postgresql & php tutorials
http://www.designmagick.com/

--
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