Forum Moderators: coopster

Message Too Old, No Replies

Add all mysql rows together that fit criteria

         

dkin

5:39 am on Jan 12, 2005 (gmt 0)

10+ Year Member



is there a function I can use to run a mysql query that grabs all rows in a database that fit the criteria and adds them together?

dreamcatcher

9:14 am on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$query = mysql_query("SELECT SUM(row) as sum_total FROM table WHERE row = 'something'") or die(mysql_error());
$row = mysql_fetch_object($query);

echo $row->sum_total;

Think that should work ok.

dc