I can't add any more variables or anything, but I need my $Monthly variable to increment by the initial value of $Monthly rather than doubling, replacing then doubling the replacement etc.
I know that it's doing this because of the increment line that says $Monthly += $Monthly; For example, if the value of $Monthly came out to be 3, it's basically taking 3 + 3 = 6 on the first iteration. Then it replaces the 3 stored in the variable with 6 and for the next iteration it does 6 + 6 = 12 and the next iteration is 12 + 12 = 24 and so on. Instead, I want the value of $Monthly after the calculations in it's variable are performed, to remain so that it works like this: 3 + 3 = 6 then on the second iteration 6 + 3 = 9 and the third would be 9 + 3 = 12 and so on. I've tried to set $Monthly as a constant, and I have searched all over for answers, but maybe I'm not doing it correctly.
Again, I can't use any more variables. Oh and $Ammount is supposed to be a constant, but beyond simply not doing anything to change it, I don't know if I set it correctly. I have searched stack over flow and I have read about constants with no such luck. My biggest issue is making the $Monthly not double and replace, but simply continue to add the initial value each time until the for loop terminates. Any help is much appreciated. Thanks.
<!--Indicates page is HTML5 compliant-->
<!DOCTYPE html>
<html>
<head>
<!--Titles the page at the top such as on the browser tab (w/ Chrome)-->
<title>Monthly & Yearly Interest</title>
<!--Pulls the CSS styling from the main.css page-->
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<main>
<h2>Yearly and Monthly Interest for $50,000 at Varying Rates</h2>
<table>
<tr><td>Rate</td><td>Annual Interest</td><td>Monthly Interest</td></tr>
<?php
// Variables
$Ammount = 50000;
$Annual= number_format(500,2);
$Percent = 1;
$Monthly = number_format($Ammount * ($Percent/100)/12,2);
//For loop to display Percent, Annual and Monthly data in their respective columns for one row
for ($counter = 1; $counter <= 10; $counter++) {
echo "<td>$Percent%</td><td>$" . number_format($Annual, 2) . "</td><td>$" . number_format($Monthly, 2) . "</td>";
//Increments
$Percent++;
$Annual+=500;
$Monthly += $Monthly;
//Next row
echo "<tr></tr>";
}
?>
</table>
</main>
</body>
</html>