[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 =
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
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
[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
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
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_
> -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
[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
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
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
10 matches
Mail list logo