The PHP script captures the values and calculates the future value. working backwards from the last month to the first, how could I compute the investment for the previous month and display the months number and the value all the way back to the first investment (Unknown). I've already figured out that I'll have to uses a formula like this "months value = (months value)/(1 + rate)" but after that I hit a road block. basically I'm trying how to figure how much do you invest today to have a balance value of $XXX after xx years at a x% interest rate?
<?php
// get the data from the form
$investment = $_POST['investment'];
$interest_rate = $_POST['interest_rate'];
$years = $_POST['years'];
// calculate the future value
$future_value = $investment;
for ($i = 1; $i <= $years; $i++) {
$future_value = ($future_value + ($future_value * $interest_rate *.01));
}
// apply currency and percent formatting
$investment_f = '$'.number_format($investment, 2);
$yearly_rate_f = $interest_rate.'%';
$future_value_f = '$'.number_format($future_value, 2);
?>