Adding numbers from separate mysql rows together and input the answer into PHP

Hi, I am racking my brain trying to figure this one out, I have a table, in it I have a field (Bill_Total) I need to know how to take the values and add them together
and put them into a PHP variable


200 mysql_result
300 mysql_result
100 mysql_result

= 600 PHP variable

I already have a bit of code that works but that will only add the two numbers I select and I need it to grow as my table will (if that makes any sense?)

select sum(Bill_Total)… sounds right? Or am I not understanding what you wish?

EDIT: sum() is an SQL aggregate function. I’m guessing you know some basic stuff about SQL. If not, you should consider studying more about it. It seems you will need it anyway.

Off Topic:

This thread should start in mySQL and after the select part is done with, maybe jump to PHP forum. It has nothing to do with CSS :slight_smile:

That was perfect, having a slight problem with decimal places but I am sure I will work that out

Cheers Again