title: Populating an html table with a PHP for loop
body: <p>For loops needed to populate table. But I keep getting an extra two columns that repeat the data in the first two columns. What am I getting wrong with my for loops? All help is appreciated.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;  
          &lt;html&gt;
              &lt;head&gt;
              &lt;meta charset="utf-8"&gt;
              &lt;title&gt;Calculating Interest&lt;/title&gt;
              &lt;style&gt;
                  table {
                      border:       3px solid black;
                      border-color: black;
                      text-align:   left;
                      padding:      1px;
                  }
                  th {
                      background-color: #01008A;
                      color: white;
                  }
                  tr:nth-child(odd) {background-color: #AED8E6}
  
              &lt;/style&gt;
              &lt;/head&gt;
          &lt;body&gt;  
              &lt;table&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Year&lt;/th&gt;
                      &lt;th&gt;Amount on deposit&lt;/th&gt;
                  &lt;/tr&gt;
                  &lt;?php  
  
  
                      for($i = 1; $i &lt;= 10; $i++) { 
                          echo "&lt;tr&gt;";  
                          for ($j = 1; $j &lt;= 2; $j++) {
                              $p = 1000;
                              $r = 0.05;
                              $n = 1;
  
                              echo "&lt;td&gt;" . $i . "&lt;/td&gt;"; 
                              echo "&lt;td&gt;" . ($p = number_format(($p * pow((1 + $r), $i)), 2)) . "&lt;/td&gt;";
                              $n++;
                          }  
                          echo "&lt;/tr&gt;";  
                      }  
                  ?&gt;  
              &lt;/table&gt;
          &lt;/body&gt;  
      &lt;/html&gt;  
  </code></pre>