PDA

View Full Version : PHP/MySQL Help



iUnknown
23-11-2008, 01:40 PM
Hello,

I'm just trying to find out the best way, or even a way of adding up one field for each row in a table in a mysql database.

What I think should make it work, isn't:


$total = "0.00";
number_format($total,2);
do {
$amount = $r['amount'];
$total = $total + $amount;
} while ($r = mysql_fetch_array($result));It returns $total as 0 (note: not 0.00, just 0).

How can I make this work?

Edit: Nevermind, it was my query $result that was the problem. Thread closed.

Want to hide these adverts? Register an account for free!