RE: [PHP] Looping Addition

2002-12-06 Thread Ford, Mike [LSS]
- 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 you

Re: [PHP] Looping Addition

2002-12-05 Thread Stephen
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 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

Re: [PHP] Looping Addition

2002-12-05 Thread 1LT John W. Holmes
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

Re: [PHP] Looping Addition

2002-12-05 Thread Stephen
: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 you've figured out how to do an array... You'll have to loop through the values like in the code

Re: [PHP] Looping Addition

2002-12-05 Thread Jason Wong
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 zero. --

Re: [PHP] Looping Addition

2002-12-05 Thread Stephen
: 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 hope you understand this now... Ah!, I think I understand better now. You want to add

Re: [PHP] Looping Addition

2002-12-05 Thread Kevin Stone
- 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 use this same method only to subtract? What I'm doing right now would

Re: [PHP] Looping Addition

2002-12-05 Thread Stephen
, 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'] as $number ) { $total -= $number;// if users inputs 5 as first value result equals -5 $total = abs($total

Re: [PHP] Looping Addition

2002-12-05 Thread 1LT John W. Holmes
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.. $total = 0;

Re: [PHP] Looping Addition

2002-12-05 Thread Stephen
No, I wasn't going to ask that. But thanks for the info. :P - Original Message - From: 1LT John W. Holmes [EMAIL PROTECTED] To: Stephen [EMAIL PROTECTED]; Kevin Stone [EMAIL PROTECTED] Cc: PHP List [EMAIL PROTECTED] Sent: Thursday, December 05, 2002 3:14 PM Subject: Re: [PHP] Looping

Re: [PHP] Looping Addition

2002-12-04 Thread Ray Hunter
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:

Re: [PHP] Looping Addition

2002-12-04 Thread Stephen
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... if( is_numeric( $_POST['vars'] ) ) { $vars = (int)$_POST['vars']; } else { echo Error: \$_POST

Re: [PHP] Looping Addition

2002-12-04 Thread Chris Wesley
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(

Re: [PHP] Looping Addition

2002-12-04 Thread Stephen
... - Original Message - From: Chris Wesley [EMAIL PROTECTED] To: PHP List [EMAIL PROTECTED] Cc: Stephen [EMAIL PROTECTED] Sent: Wednesday, December 04, 2002 7:44 PM Subject: Re: [PHP] Looping Addition On Wed, 4 Dec 2002, Stephen wrote: I already have that. $_POST['vars'] is a number and I

Re: [PHP] Looping Addition

2002-12-04 Thread Tom Rogers
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

Re: [PHP] Looping Addition

2002-12-04 Thread Chris Wesley
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,

Re: [PHP] Looping Addition

2002-12-04 Thread 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... Then I calculate it. My question is, how would I loop the adding? I hope you

RE: [PHP] Looping Addition

2002-12-04 Thread John W. Holmes
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: form name=add method=post action=?php