Forum Moderators: coopster
What I would like to do is have this page done via the database route.
Now I have the mysql db set up as follows
transid ¦ date ¦ description ¦ deposits ¦ withdrawals ¦
The problem I have is in showing the running balance after every transaction. What should happen is in every row it should total the deposit of that row plus the previous rows, minus the withdrawals from all previous rows as well. How would I set that up in the php code?
$balance = 0;
while ($row_finance = mysql_fetch_assoc($finance)){
$balance .= $balance + $row_finance[deposit] - $row_finance[withdrawal];
echo $row_finance[date]." ¦ ".$row_finance[description]." ¦ ".$row_finance[deposit]." ¦ ".$row_finance[withdrawal]." ¦ ".$balance;
}
but that doesn't work as it isn't doing the addition/substration. It just adds it on.