Quantcast
Channel: ASPRunner forums
Viewing all articles
Browse latest Browse all 2586

Storing running total

$
0
0
I was able to get this to work before, but I can't get it to work anymore for some reason. What I was looking to get done was have a transaction log for banking/account balance purposes. This is for a small organization, so once a value is added, they cannot go back to edit the cost. I have the following setup:

Table 1 (bod_account)
-Account ID
-Account Name

Table 2 (bod_transactions)
-credit
-debit
-balance

I have separate Add Expense and Add Deposit pages. Using the Add Deposit Page, I have the following code:

Before Record Added:
$sql = "SELECT MAX(balance) AS total FROM bod_transactions";
$rs = CustomQuery($sql);
$data = db_fetch_array($rs);
$values['balance'] = $values['total'] + $data["credit"];


After Record Added
CustomQuery("update bod_account set balance=balance+" . $values["credit"] . " where account_id = 1" );


When a Deposit is added, the After Record Added works just fine by updating the final balance on table 1. What's not working is for the bod_transactions table with the Before Record Added, where it needs to read the last balance, and add to that to derive a new balance for the new deposit. I'm just trying to store the running balance, as using a dynamically created running total won't work between pagination. Can't figure out why this isn't working for some reason on v10.

Also, if Sergey is the one who reads and replies and you were the one who sent the last e-mail about the hacker, I commend you with the patience with GoDaddy. I have my website through godaddy, and after reading your experience, I will be moving it as soon as my contract is up.

Viewing all articles
Browse latest Browse all 2586