If you visit the following [B][URL=”http://tinyurl.com/ytc55b”]url
here is my code:
[code=php]<?php
// 52 – Weekly
// 26 – Biweekly
// 12 – Monthly
// 6 – Bimonthly
$period = 12;
function calculateMortgage($balance,$rate,$term){
global $period;
$N = $term * $period;
$I = ($rate/100)/$period;
$v = pow((1+$I),$N);
$t = ($I*$v)/($v-1);
$result = $balance*$t;
return $result;
}
$balance = isset($_POST[‘balance’]) ? $_POST[‘balance’] : ”;
$rate = isset($_POST[‘rate’]) ? $_POST[‘rate’] : ”;
$term = isset($_POST[‘term’]) ? $_POST[‘term’] : ”;
?>
[code=php] <div id=”main_calc”><!– calc start –>
<div class=”caption1″>Mortgage Repayment Calculator</div>
<form action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>” method=”post” >
<table width=”345px” class=”calc_form”>
<tr>
<td>Loan Balance:</td>
<td><input class=”text” name=”balance” type=”text” size=”15″ value=”<?php echo $balance; ?>” /> €</td>
</tr>
<tr>
<td>Interest Rate:</td>
<td><input class=”text” name=”rate” type=”text” size=”5″ value=”<?php echo $rate; ?>” />
%</td>
</tr>
<tr>
<td>Loan Term:</td>
<td><input class=”text” name=”term” type=”text” size=”5″ value=”<?php echo $term; ?>” />
years</td>
</tr>
<tr>
<td></td>
<td align=”left”><br/>
<input class=”text” type=”submit” name=”submitBtn” value=”Calculate” /></td>
</tr>
</table>
</form>
<?php
if ((isset($_POST[‘submitBtn’]) && ($balance != ”) && ($rate != ”) && ($term != ”))){
?>
<div class=”caption2″>Result</div>
<div id=”result”>
<table width=”345px”>
<?php
$pay = round(calculateMortgage($balance,$rate,$term),2);
echo “<tr><td class=’res_heading’>Monthly Payment:</td><td class=’res’> €”.$pay.”</td></tr>”;
echo “<tr><td class=’res_heading’>Total Interest:</td><td class=’int’> €”.(($term*$pay*$period)-$balance).”</td></tr>”;
?>
</table>
<?php
echo “<br/><br/>”;
echo “<table class=’detail’>”;
echo “<tr><td>Month</td><td>Principial</td><td>Interest</td><td>Payment</td></tr>”;
for ($i=0;$i<($term*$period);$i++){
$tmp = (($pay) – ($balance*($rate/100/$period)));
$diff = round($tmp,2);
$int = round(($balance*$rate/100/$period),2);
$princ = $balance – $diff;
$balance = round($balance,0);
echo “<tr><td>$i. month</td><td> $”.number_format($balance).”</td><td> $”.number_format($int).”</td><td> $”.number_format($pay).”</td></tr>”;
$balance = $princ;
}
echo “</table>”;
?>
</div>
<?php
}
?>
</div> <!– calc end –>
Is this possible to do, if so does anyone know how, thanks in advance