title: HTML forms with PHP and MySql
body: <p>The problem I am having is that I would like when the option is selected and the submit button is pressed, the table in MySQL should be updated. After the update the new table should be displayed on the form. This is a school grade table and the teacher should be able to change the grades. I can not seem to make it work.</p>
  
  <pre><code>$courseSct = "SELECT username, courseName, grade, gradeID FROM Courses\n"
                      . "JOIN Grades\n"
                      . "ON courses.courseId = Grades.courseId";
      $result = $connection-&gt;query($courseSct);
      $rows = $result-&gt;num_rows;
  
  
  
      for($j = 0; $j &lt; $rows; ++$j)
      {
          $result-&gt;data_seek($j);
          $row = $result-&gt;fetch_array(MYSQLI_NUM);
  
          echo 'User Name: ' . "\t\t" . $row[0];
          echo "\t" . 'Course Name:' . "\t\t" . $row[1] . "\t\t";       
          echo "\t" . 'Grade:' . "\t" . $row[2]; 
          echo '&lt;select name="grade" size="1" id="' . $row[3] . '"&gt;
              &lt;option value="select"&gt;Select&lt;/option&gt;
              &lt;option value="A"&gt;A&lt;/option&gt;
              &lt;option value="B"&gt;B&lt;/option&gt;
              &lt;option value="C"&gt;C&lt;/option&gt;
              &lt;option value="D"&gt;D&lt;/option&gt;
              &lt;option value="F"&gt;F&lt;/option&gt;
              &lt;option value="I"&gt;I&lt;/option&gt;
          &lt;/select&gt;&lt;br&gt;';
          if (isset($_POST['submit']))
          {
              $courseSct = "UPDATE Grades SET grade=\'$row[2]\' "
                         . "WHERE id=\'$row[3]\'";
              $result = $connection-&gt;query($courseSct);
              //$row[2] = '$row[3]';
              //echo "This is the updated grades table &lt;br&gt;&lt;br&gt;";
          }
  </code></pre>