- Original Message -
From: "Chris Wesley" <[EMAIL PROTECTED]>
To: "PHP List" <[EMAIL PROTECTED]>
> 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
yo
PROTECTED]>
Sent: Thursday, December 05, 2002 3:14 PM
Subject: Re: [PHP] Looping Addition
> > But then, if the user entered 5 - 6, it should be -1 but it'd return
> > positive one... Is there another way?
>
> Come on, man... this is addition and subtraction. You c
> But then, if the user entered 5 - 6, it should be -1 but it'd return
> positive one... Is there another way?
Come on, man... this is addition and subtraction. You can't figure it out?
> > You simply need the absolute value of the difference. So taking
Stephen's
> > example below..
> >
> > $tot
gt;
Cc: "PHP List" <[EMAIL PROTECTED]>
Sent: Thursday, December 05, 2002 2:51 PM
Subject: Re: [PHP] Looping Addition
> You simply need the absolute value of the difference. So taking Stephen's
> example below..
>
> $total = 0;
> foreach( $_POST['nums
riginal Message -
From: "Stephen" <[EMAIL PROTECTED]>
To: "Chris Wesley" <[EMAIL PROTECTED]>
Cc: "PHP List" <[EMAIL PROTECTED]>
Sent: Thursday, December 05, 2002 12:33 PM
Subject: Re: [PHP] Looping Addition
> Continuing this even more...how would I
AIL PROTECTED]>
Sent: Wednesday, December 04, 2002 8:42 PM
Subject: Re: [PHP] Looping Addition
> 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
On Thursday 05 December 2002 23:05, Stephen wrote:
> So would I just put this?
>
> foreach(%_POST['number'] as $num)
> {
> $output *= $num;
> }
> echo $output;
>
> That's for multiplication.
Yes. Wouldn't it have been quicker for you to try it than to ask?
BTW make sure that none of $num is z
: "PHP List" <[EMAIL PROTECTED]>
Sent: Thursday, December 05, 2002 8:24 AM
Subject: Re: [PHP] Looping Addition
> > One more question... If I then wanted to do this for the other
operations
> > (such as multiplication, division, etc), how would I do that?
>
> Assuming yo
> One more question... If I then wanted to do this for the other operations
> (such as multiplication, division, etc), how would I do that?
Assuming you've figured out how to do an array...
You'll have to loop through the values like in the code that others posted.
foreach($_POST['number'] as $n
27;Chris Wesley'"
<[EMAIL PROTECTED]>
Cc: "'PHP List'" <[EMAIL PROTECTED]>
Sent: Wednesday, December 04, 2002 9:01 PM
Subject: RE: [PHP] Looping Addition
> > Let me explain this as best I can. The user enters how many numbers he
> > wants
>
> Let me explain this as best I can. The user enters how many numbers he
> wants
> to add. This form goes to another page. This page loops a form field
and
> it's name is "num" and after num is the number it is currently on.
Here's
> the code:
>
>
>
> How many numbers to add:
>
st" <[EMAIL PROTECTED]>
Cc: "Stephen" <[EMAIL PROTECTED]>
Sent: Wednesday, December 04, 2002 8:42 PM
Subject: Re: [PHP] Looping Addition
> On Wed, 4 Dec 2002, Stephen wrote:
> > This is only a snippet, there is more to it but for simplicities sake...
> >
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, w
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 u
e...
Then I calculate it. My question is, how would I loop the adding? I hope you
understand this now...
- Original Message -
From: "Chris Wesley" <[EMAIL PROTECTED]>
To: "PHP List" <[EMAIL PROTECTED]>
Cc: "Stephen" <[EMAIL PROTECTED]>
Se
On Wed, 4 Dec 2002, Stephen wrote:
> I already have that. $_POST['vars'] is a number and I already check that you
> on a page before. All I need to know is how to keep adding numbers until
> there are no more to add...
If you mean that $_POST['vars'] is an array of numbers:
$total = 0;
foreach(
t; <[EMAIL PROTECTED]>
Cc: "PHP List" <[EMAIL PROTECTED]>
Sent: Wednesday, December 04, 2002 4:33 PM
Subject: Re: [PHP] Looping Addition
> What type is $_POST['vars']? I think that it is a string...you might
> have to convert it to an integer...
>
>
What type is $_POST['vars']? I think that it is a string...you might
have to convert it to an integer...
if( is_numeric( $_POST['vars'] ) )
{
$vars = (int)$_POST['vars'];
}
else
{
echo "Error: \$_POST['vars'] is not an integer.";
}
On Wed, 2002-12-04 at 14:26, Stephen wrote:
> So
Sorry for the uncontrolable emaling to the list but I'm in rather a stump.
You may be hearing a lot from me over the next few days too.
Anyway, I mentioned before my form with the addition that loops to the
number of numbers the user wants to add. Now to the part of the actual
addition, how could
19 matches
Mail list logo