Jon Bennett wrote:
Hi,

I've got a dynamically generated form and once it's submitted I need to _push the data from my form elements into an array so I can ad them to the db. My form elements are created like so:

<?php

$i = 1;

while ($i <= $iListItems){

?>

<div class="row">
<div class="label">List Item <?php print $i ?>:</div><div class="formw"><input type="text" name="listItem<?php print $i ?>" size="40" /></div>
</div>

Why don't you just skip the whole "$i" counter thing and name your input elements as "listItem[]" ? Name every one of them that; the same thing. Now when you submit your form, you'll already have an array, $_POST['listItem']. $_POST['listItem'][0] will be what was in the first one, $_POST['listItem'][1] in the second, etc.


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

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



Reply via email to