This topic is locked

For those asking about totals

6/4/2007 8:15:26 PM
PHPRunner Tips and Tricks
J
jim9 author

I see a lot of folks asking about totals, support helped me figure this out a while back, see this link.

running totals
In fact, the below code is used for a ledger where you have deposits and withdrawals, there is a deposit column and a withdrawal column. The rbal column keeps up with the running total. Works like a champ. This is set as properties behind the rbal field.

global $data,$conn;

$str = "select sum(DepositAmount) - sum(WithdrawalAmount) from transactions1 where TN<=".$data["TN"];

$rs = db_query($str,$conn);

$data = db_fetch_numarray($rs);

$value = $data[0];

H
hugolesme 7/18/2007

Where I have to put the code?

J
jim9 author 7/18/2007

As stated above, in the properties. Rt click on the field you're using for a balance, and choose properties, then custom, etc.

Where I have to put the code?

K
kwebb 3/13/2008

$str = "select sum(DepositAmount) - sum(WithdrawalAmount) from transactions1 where TN<=".$data["TN"];
Based on this string I see your field names for "deposit" and "withdraw" along with table name but what is the "TN" field

Did you create an additional field that your populating the data into other than your rbal field?

S
smcgo4 3/13/2008

$str = "select sum(DepositAmount) - sum(WithdrawalAmount) from transactions1 where TN<=".$data["TN"];

Based on this string I see your field names for "deposit" and "withdraw" along with table name but what is the "TN" field

Did you create an additional field that your populating the data into other than your rbal field?

I am guessing TN stands for Transaction Number - a key field.

K
kwebb 3/14/2008

That was it.... Thanks