RE: [PHP] Sum a column of values from a MySQL query
| From: | Ben C. | Date: | Tue, 05 Aug 2003 07:43:31 +0000 |
| Subject: | RE: [PHP] Sum a column of values from a MySQL query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158249@lists.php.net to get a copy of this message | ||
Yes, I know. However, the while() loop should generate all the invoice in a
list.
-----Original Message-----
From: Giz [mailto:gizmo@gizmola.com]
Sent: Tuesday, August 05, 2003 12:03 AM
To: 'Ben C.'; php-general@lists.php.net
Subject: RE: [PHP] Sum a column of values from a MySQL query
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:benc@cox.net]
Sent: Monday, August 04, 2003 11:42 PM
To: php-general@lists.php.net
Subject: [PHP] Sum a column of values from a MySQL query
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_2 = @mysql_query($sql_2,$connection) or die(mysql_error());
while ($row = mysql_fetch_array($result_2)) {
$invoicepartpaid = $row['partpaid'];
}
---END CODE #2----------------
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php