Hi Rich,

$iListItems is set when a user chooses how many list elements they require (this is for the example pages I was asking about) and is always greater than 0 (we don't get this far in the script if it's not!).

Anyway, it was my silly fault, I had changed the name of my form elements whilst trying to fix it but hadn't gone back to the very begining in my browser so my loop was looking for the wrong post names! Doh!

Thanks,

Jon


jon bennett | [EMAIL PROTECTED] 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/


On 16 Jan 2004, at 15:36, Richard Davey wrote:


Hello Jon,

Friday, January 16, 2004, 3:29:07 PM, you wrote:

JB> And after the form is submitted I assumed I could do this...

JB> $aListItems = array();

JB> $i = 1;

JB> while ($i <= $iListItems) {

JB>  $tempItem = $_POST["listItem" . $i];
JB>  array_push($aListItems, $tempItem);
JB>  ++$i;
JB> }

JB> print_r ($aListItems);

JB> but nothing appears to be added to the db, how can I access the $_POST
JB> vars within a loop ??


I can't see the whole script, so this is just guess work - but your
loop is checking to see if $i (1) is less than $iListItems, but as far
as I can see this isn't defined anywhere in your code, so the loop
will never actually go through because it's saying 1 <= 0.

Where is $iListItems set and to what value?

Your loop will work, but it's not obvious it's getting the chance to.

Also you don't need to array_push it, you could just do:

$aListItems[] = $tempItem;

--
Best regards,
 Richard                            mailto:[EMAIL PROTECTED]



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



Reply via email to