There are a number of approaches that you can take, I'll show you one initially. Since the values are being brought out of a database (assuming MySQL) then there are functions which you can use in the query to pull back the information you're looking for.
To total up a column of data, you can use:
Note: Replace mycolumn and mytable as appropriate
Code:
SELECT SUM(mycolumn) FROM mytable
Other similar functions like AVG (average), MAX (max value), MIN, COUNT (number of rows returned) can also be used.