Re: [PHP] Sum of results

2008-01-30 Thread Richard Lynch
On Wed, January 30, 2008 12:58 am, Dax Solomon Umaming wrote: > Hi; > > I've tried Googling this out but failed to search for an answer to > this, so > I'm posting to this list. I'd like to know if there's a way to get the > sum > this results: > > // Results > Individual Daily Consumption > //Ac

Re: [PHP] Sum of results

2008-01-29 Thread Nathan Nobbe
On Jan 30, 2008 1:58 AM, Dax Solomon Umaming <[EMAIL PROTECTED]> wrote: > I've tried Googling this out but failed to search for an answer to this, so > I'm posting to this list. I'd like to know if there's a way to get the sum > this results: you can simply sum them as you print the report $sum =

RE: [PHP] Sum a column of values from a MySQL query

2003-08-14 Thread Jay Blanchard
[snip] Sorry, Jay, but that's a horrible method. You could just run one query with a GROUP BY clause to get the sum for each invoiceID, instead of running multiple queries like you've mentioned... $query = "SELECT invoiceid, SUM(partpaidamount) AS partpaid FROM $tb_name GROUP BY invoiceid"; $rs =

RE: [PHP] Sum a column of values from a MySQL query

2003-08-14 Thread Giz
I think you're a big confused here. Your query will only return one row, because you're using sum(). $invoicepartpaid will be your total for the invoiceid specified. -Original Message- From: Ben C. [mailto:[EMAIL PROTECTED] Sent: Monday, August 04, 2003 11:42 PM To: [EMAIL PROTECTED] Su

Re: [PHP] Sum a column of values from a MySQL query

2003-08-14 Thread Miles Thompson
From bitter experience I'll suggest that it's a REALLY GOOD idea to store invoice totals, subtotals, etc. in either the invoice header record. If not rounding errors, or some small change in logic, can come back and bite you - accountants get *really* upset when that 3000.00 invoice becomes 3000

RE: [PHP] Sum a column of values from a MySQL query

2003-08-14 Thread Jay Blanchard
[snip] 1) The code returns the sum of a partially paid invoice. The individual invoice is 'partpaid'. WORKS...NO PROBLEM 2) The while() then return a list of partially paid invoices which is $invoicepartpaid. WORKS..NO PROBLEM 3) I then want to add the list of partially paid invoices ($invoicepar

Re: [PHP] Sum a column of values from a MySQL query

2003-08-14 Thread CPT John W. Holmes
Message - From: "Jay Blanchard" <[EMAIL PROTECTED]> To: "Ben C." <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, August 05, 2003 8:29 AM Subject: RE: [PHP] Sum a column of values from a MySQL query [snip] 1) The code returns the sum of a partiall

Re: [PHP] Sum a column of values from a MySQL query

2003-08-07 Thread Adam Alkins
Quoting "Ben C." <[EMAIL PROTECTED]>: > I am trying to sum a query of values from a MySQL table. The code I am > using is: > > ---BEGIN CODE #1-- > $sql_2 = "SELECT SUM(partpaidamount) as partpaid > FROM $tb_name > WHERE invoiceid = \"$invoiceid\" > "; > > $result_

RE: [PHP] Sum a column of values from a MySQL query

2003-08-05 Thread Ford, Mike [LSS]
> -Original Message- > From: Ben C. [mailto:[EMAIL PROTECTED] > Sent: 05 August 2003 07:42 > > I am trying to sum a query of values from a MySQL table. The > code I am > using is: > > ---BEGIN CODE #1-- > $sql_2 = "SELECT SUM(partpaidamount) as partpaid > FROM $tb_name

RE: [PHP] Sum a column of values from a MySQL query

2003-08-05 Thread Jay Blanchard
[snip] However, why not just SUM all the rows in the table in the query if you just want a total? $sql_2 = "SELECT SUM(partpaidamount) as partpaid FROM $tb_name"; [/snip] That is what he is doing. The SELECT SUM will only return ONE row! I am not sure that the problem is being explained clearly t

Re: [PHP] Sum a column of values from a MySQL query

2003-08-05 Thread Jason Wong
On Tuesday 05 August 2003 15:43, Ben C. wrote: > Yes, I know. However, the while() loop should generate all the invoice in > a list. As has been pointed out the query only results in a single row. So how would the while-loop "generate all the invoice[s]"? It's only ever given a single row to pl

RE: [PHP] Sum a column of values from a MySQL query

2003-08-05 Thread Ben C.
Yes, I know. However, the while() loop should generate all the invoice in a list. -Original Message- From: Giz [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 05, 2003 12:03 AM To: 'Ben C.'; [EMAIL PROTECTED] Subject: RE: [PHP] Sum a column of values from a MySQL query I thin

Re: [PHP] sum

2002-05-06 Thread Analysis & Solutions
On Mon, May 06, 2002 at 10:01:00AM -0700, Fifield, Mike wrote: > amounts stored "float" values. But what I get back it something like this > "98.18855591" it is to precise. All I want is the dolor amounts added up > and rounded up to the closest penny. Is there a better value type to use or

Re: [PHP] Sum function

2001-02-18 Thread David Robley
On Mon, 19 Feb 2001 06:57, Claudia wrote: > I am looking for code that explains how to sum a value in a database > based on a current field retrieved from the database. > > Example: > > query = "select course_name, course_build, milestone, testcase, > time_tested, issue_status, comment, >bug_n

Re: [PHP] Sum from Arrays ?

2001-02-07 Thread Reuben D Budiardja
Try this: for($i=0;$i < count($the_array); $i++) $sum = $sum + $the_array[$i]; or if the index of your array is not in order, try this: while($element = array_pop($the_array)) $sum = $sum + $element; Hope that helps. Rdb At 06:38 PM 2/7/01 +0100, you wrote: >No I've explained this

Re: [PHP] Sum from Arrays ?

2001-02-07 Thread Philip Olson
As of PHP 4.0.4 the function array_sum() exists (it's undocumented, but in changelog), it's used as such : $array = array(1,3,5); $sum = array_sum($array); Or loop through array as such : foreach ($array as $value) { $sum += $value; } Either way, $sum now equals 9

Re: [PHP] Sum from Arrays ?

2001-02-07 Thread Keith Whyman
No I've explained this badly I've got the array $a what I want is a sum of what's in the array ie from your sample the answer would be 1+3+5 = 9 Thanks Keith > Hum, maybe the count() function. Works with mysql_fetch_array() too. Here's > a sample: > $a[0] = 1; > $a[1] = 3; > $a[2] = 5; > $resul

Re: [PHP] Sum from Arrays ?

2001-02-07 Thread Shane McBride
Hum, maybe the count() function. Works with mysql_fetch_array() too. Here's a sample: $a[0] = 1; $a[1] = 3; $a[2] = 5; $result = count ($a); //$result == 3 Here's a link: http://php.net/manual/en/function.count.php DISCLAIMER: I am by no means well-versed in this, or any other, topic - Shane