Re: Looping Addition
| From: | Tom Rogers | Date: | Thu, 05 Dec 2002 01:42:35 +0000 |
| Subject: | Re: Looping Addition | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-127081@lists.php.net to get a copy of this message | ||
Hi,
Thursday, December 5, 2002, 7:26:57 AM, you wrote:
S> Sorry for the uncontrolable emaling to the list but I'm in rather a stump.
S> You may be hearing a lot from me over the next few days too.
S> Anyway, I mentioned before my form with the addition that loops to the
S> number of numbers the user wants to add. Now to the part of the actual
S> addition, how could I loop that out also?
S> Here's what I'm trying to do right now but naturally, it doesn't work:
S> $output = 0;
S> $current = 1;
S> do
S> {
S> $output .= $num.$current +
S> $current++;
S> } while($current <= $_POST['vars']);
S> Any help would be great! Thanks!
S> Thanks,
S> Stephen Craton
S> http://www.melchior.us
S> "What is a dreamer that cannot persevere?" --
S> http://www.melchior.us
something like
$output = 0;
$current = 1;
do
{
$x = 'num'.$current;
if(isset($_POST[$x])){
$output += $_POST[$x];
}
$current++;
} while($current <= $_POST['vars']);
--
regards,
Tom