dynamic array creation from form elements

From: Date: Fri, 16 Jan 2004 15:29:07 +0000
Subject: dynamic array creation from form elements
Groups: php.general 
Request: Send a blank email to php-general+get-174823@lists.php.net to get a copy of this message
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> <?php
    ++$i;
?> <?php } // end while ?> And after the form is submitted I assumed I could do this... $aListItems = array(); $i = 1; while ($i <= $iListItems) { $tempItem = $_POST["listItem" . $i]; array_push($aListItems, $tempItem); ++$i; } print_r ($aListItems); but nothing appears to be added to the db, how can I access the $_POST vars within a loop ?? Thanks, Jon jon bennett | jon@jben.net new media creative _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ J b e n . n e t 91 Gloucester Rd, Trowbridge, Wilts, BA14 0AD t: +44 (0) 1225 341039 w: http://www.jben.net/

« previous php.general (#174823) next »