1. Lets say i have a lettle script that pretends it is a bank. I can deposit or withdraw money. How can i make it have a 5% interest each day? So one day I have put in 100 dollars and the next there should be 105 dollars. I am open to anyway to do this.

2.

3. [searchweb]amortization algorithm[/searchweb]

4. Actually, scratch that. You're going to have to store the following info in your database"

account_types
--------
account_type_id
interest_rate
compound
minimum_balance

accounts
--------
user_id
account_type
balance
balance_as_of (date)

transactions
--------
account_id
amount
date

To find out the balance at any given moment, you will have to compound each transaction by the interest rate per unit of time elapsed (e.g. day). Of course, you could add some complexity to the system by maintaining a running total (which would then increase performance, but would also require some periodic daemon execution).

5. Run a cron job daily?

Select all of the values from the database, then use Money in account * 1.05 and have all the new values entered back in. However, if the database is large then it will take some time to process.

6. I guess you could also get the increase by adding a timestamp column to the table containing the amount.

Every time you alter data in a row, a new timestamp (current date) will automatically be generated. This way you could extract the amount of days that has passed since the last time you extracted/inserted data into that row, and use that amount of days to create a loop iterating a calculation of 1.05 for the amount of days since the data last was altered.
The final result is displayed and reinserted into the table, thus generating a new current timestamp to be used the next time the data is displayed.

7. rosland, that's exactly what I said to do... only using different words to explain it.

8. Umm.. go take pre-algebra. There's a simple formula that I have written down somewhere that'll calculate it for any amount of days. There's all kinds of formulas around intrest..

9. i have it figured out now thanks for the help guys. BTW i am a freshmen in highschool and am in Algebra 2

10. Transio, I see that now.

You sketched out a DB setup for a complete accounting system including transactions. It got a bit too complex for me, so I missed out/didn't understand the:
..you will have to compound each transaction by the interest rate per unit of time elapsed (e.g. day)..
At the time, it appeared you and JR where talking about some daemon/cron functionality while I thought I suggested a simpler setup (for the calculation of interest rate)

Didn't mean to repeat your post. :cross-eyed:

11. I just learned that lol

Ammount = Initial x (1+ (percentage/times per year ))^(times per year x number of years)

for coninually compounded intrest its

ammount = initial x e^(percentage x number of years)