Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 18th, 2006, 03:32 PM
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default summing column values

how can i sum column values from mysql result within my php script. my query is
query = mysql_query(select sum(debit), sum(credit), sum(balance) from table where office = 'james');
please someone help
thank you

 
Old December 8th, 2006, 04:54 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

$query = mysql_query("select sum(debit) as t1, sum(credit) as t2, sum(balance) as t3 from table where office = 'james'");
while($row = mysql_fetch_array($query)){
$fulltotal=$row['t1']+$row['t2']+$row['t3'];
echo($fulltotal);
}

surendran
(Anything is Possible)
http://ssuren.spaces.msn.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the Sum of all the values in a column.. jhansib4u ADO.NET 1 December 1st, 2007 09:15 PM
Summing values swwallace XSLT 4 March 4th, 2006 12:13 PM
Concatenating column values arnabghosh Access 1 September 21st, 2005 06:45 AM
Datagrid column values pankaj_daga ASP.NET 1.0 and 1.1 Basics 4 November 17th, 2003 05:51 PM
TSQL to get column values mstuart60 SQL Language 2 June 9th, 2003 04:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.