...

View Full Version : add up all mysql rows and then echo it out in php..



webandwe
08-25-2007, 07:10 PM
Hi,

I have a database with a row called "time".

I need to somehow add up all the time rows and then echo out the total in php. How do I do it?

Example

MySQL
-----------
1. time 30
2. time 10
3. time 20

php
----------------


$total_time = ( addup all SQL rows FROM Time);

echo"$total_time min";
---------------------------------

Result:

60 min

Thanks

Fumigator
08-25-2007, 07:45 PM
SELECT SUM(time_column)
FROM your_table


If you are unsure how to do a MySQL query in PHP, refer to the manual, mysql_query() (http://us2.php.net/manual/en/function.mysql-query.php) function. Very simple code example on that page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum