On Wed, 4 Dec 2002, Stephen wrote:
> This is only a snippet, there is more to it but for simplicities sake...
> Then I calculate it. My question is, how would I loop the adding? I hope you
> understand this now...

Ah!, I think I understand better now.  You want to add num1, num2, num3,
... numN, which are inputs from the second form in your sequence.  Gotcha.

If you name /all/ the form elements as "nums[]" instead of individually as
"num${current}", the numbers put into the form will all be accessible in
one array to the PHP script that does the adding.  Then you can just loop
over the array of numbers.

In your second form, change this:
"<input name="num<?php echo $current; ?>" type="text" id="vars" value="0"
 size="25">"

To this:
"<input name="nums[]" type="text" id="vars" value="0" size="25">

Then in the script that adds the numbers:
$total = 0;
foreach( $_POST['nums'] as $number ){
        $total += $number;
}

Hopefully I understood your problem this time!  Let me know if I missed
again.
        g.luck,
        ~Chris


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

Reply via email to