Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

1. ## Math Problem

I have a script that makes compound interest graphs, but whenever it gets past \$1000 it goes back to one.
Code:
```1. \$10000 × 0.12 = 1200 + \$10000 = \$11,200.00
2. \$11,200.00 × 0.12 = 1.32 + \$11,200.00 = \$12.32
3. \$12.32 × 0.12 = 1.48 + \$12.32 = \$13.80
4. \$13.80 × 0.12 = 1.66 + \$13.80 = \$15.46```
The Php is:
PHP Code:
``` <?php \$per2 = \$_POST['per']; \$per = \$per2 * .01; \$poi = "Percent Of Interest: " . \$per2 . "%<br>"; \$years = \$_POST['years']; \$prin = \$_POST['prin']; \$prin2 = round(\$prin, 2); echo "Principal: " . \$prin2 . "<br>"; echo \$poi; echo "Years: " . \$years . "<br>"; echo "Principal &times; Percent of Interest = Interest + Principal = New Principal after one year<br>"; ?> <div style="text-decoration: underline"> <?php \$a = 0; \$b = 0; while (\$a < \$years) { \$b++; \$val = round(\$prin2 * \$per, 2); \$val2 = number_format(\$val + \$prin2, 2); echo \$b . ". \$" . \$prin2 . " &times; " . \$per . " = " . \$val . " + \$" . \$prin2 . " = <b>\$" . \$val2 . "</b><br>"; \$prin2 = \$val2; \$a++; } ?> </div> ```
And the HTML for the form is:
Code:
```<html>
<title>Compounding Interest Calculator</title>
<body>
<!-- DONT MIND THIS. DIFFERENT FORM -->
<div style="float: right;">
<form action="stock.php" method="post">
Stock Names/Shares<br>
Symbol: <input type="text" name="s1"> Shares: <input type="text" name="sc1"><br>
Symbol: <input type="text" name="s2"> Shares: <input type="text" name="sc2"><br>
Symbol: <input type="text" name="s3"> Shares: <input type="text" name="sc3"><br>
Symbol: <input type="text" name="s4"> Shares: <input type="text" name="sc4"><br>
Symbol: <input type="text" name="s5"> Shares: <input type="text" name="sc5"><br>
<input type="submit" value="Do it!">
-->
</form>
</div>
<!-- THIS IS THE FORM
<form action="int.php" method="post">
Years:<br><input type="text" name="years"><br>
Principal:<br><input type="text" name="prin"><br>
Interest Percent:<br><input type="text" name="per"><br>
<input type="submit" value="Do it!">
-->
</form>
</body>
</html>```
In the actual code there are no `<!-- -->`'s by the way.

• Ahh... Nevermind. I changed `\$val2 = number_format(\$val + \$prin2, 2); ` to `\$val2 = \$val + \$prin2;`

Then I put the number_format() in the echo

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•