title: Refresh previous form table after submit button
body: <p>How do I refresh the table when I click EDIT NOW Button? or this is easier, how do I make refresh button to refresh the table? I have no knowledge on JSP to auto refresh. However, I manage to make an onchange event so when I choose menu, it will refresh upon changing. When I edit a data and submit, it does not refresh. How do I re-execute the echo of table? Thanks!</p>
  
  <p><a href="https://i.stack.imgur.com/S5yYo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S5yYo.jpg" alt="enter image description here"></a></p>
  
  <pre><code>    &lt;?php
  
  
  
      $selected='';
  
      function get_options($select)
      {
          $conn = new mysqli('localhost', 'root', 'jared17', 'hbadb') 
          or die ('Cannot connect to db');
  
          $result = $conn-&gt;query("select * from students");
  
          $options='';
          while ($row = $result-&gt;fetch_assoc()) 
          {
              $LRN = $row['LRN'];
               $Last = $row['Last_Name']; 
              $First = $row['First_Name'];
              if($LRN == $_GET['Students'])
              {
                  $options.='&lt;option value="'.$LRN.'" selected&gt;'.$Last.', '.$First.'&lt;/option&gt;';
  
              }
              else
              {
                  $options.='&lt;option value="'.$LRN.'"&gt;'.$Last.', '.$First.'&lt;/option&gt;';
              }
          }
          return $options;
      }
          if (isset($_GET['Students'])) {
              $conn = new mysqli('localhost', 'root', 'jared17', 'hbadb') 
          or die ('Cannot connect to db');
  
          $result = $conn-&gt;query("select * from students");
          $lrn = $_GET['Students'];
          $stmt = $conn-&gt;prepare("SELECT Last_Name, First_Name, Level, Q1, Q2, Q3, Q4, FINAL FROM english WHERE LRN = ?");
          $stmt-&gt;bind_param('i', $lrn);
          $stmt-&gt;execute();
          $stmt-&gt;bind_result($last, $first, $level, $q1, $q2, $q3, $q4, $final);
          $stmt-&gt;fetch();
          echo "&lt;table&gt;&lt;tr&gt;&lt;th&gt;LRN&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Level&lt;/th&gt;&lt;th&gt;Q1&lt;/th&gt;&lt;th&gt;Q2&lt;/th&gt;&lt;th&gt;Q3&lt;/th&gt;&lt;th&gt;Q4&lt;/th&gt;&lt;th&gt;Final&lt;/th&gt;&lt;/tr&gt;";
          echo "&lt;tr&gt;&lt;td&gt;$lrn&lt;/td&gt;&lt;td&gt;$last, $first&lt;/td&gt;&lt;td&gt;$level&lt;/td&gt;&lt;td&gt;$q1&lt;/td&gt;&lt;td&gt;$q2&lt;/td&gt;&lt;td&gt;$q3&lt;/td&gt;&lt;td&gt;$q4&lt;/td&gt;&lt;td&gt;$final&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
      }
  
  
  
  
      echo "&lt;html&gt;";
      echo "&lt;body&gt;";
      echo "&lt;form method=GET&gt;";
      echo "&lt;select name=Students onchange=this.form.submit();&gt;";
  
          echo get_options();
  
  
  
      echo "&lt;/select&gt;";
      echo "&lt;/form&gt;";
  
      echo "&lt;form method=POST&gt;";
      ///////////EDIT DATA
      echo "Edit Data: ";
      echo "&lt;select name = 'Edit'&gt;";
  
      echo '&lt;option value=Q1&gt;Q1&lt;/option&gt;';
      echo '&lt;option value=Q2&gt;Q2&lt;/option&gt;';
      echo '&lt;option value=Q3&gt;Q3&lt;/option&gt;';
      echo '&lt;option value=Q4&gt;Q4&lt;/option&gt;';
      echo '&lt;option value=FINAL&gt;FINAL&lt;/option&gt;';
      echo '&lt;input type="number" max="100" name="editdata" required&gt;';
      echo "&lt;/select&gt;";
      echo "&lt;input type='submit' name='submit2' value='Edit Now'&gt;";
  
  
      if (isset($_POST['Edit'])) {
          $conn2 = new mysqli('localhost', 'root', 'jared17', 'hbadb') 
          or die ('Cannot connect to db');
          $upd = $_POST['Edit'];
          $txt = $_POST['editdata'];
          $now = "UPDATE english SET $upd='$txt' WHERE LRN='$lrn'";
          $res = $conn2-&gt;query($now);
          if (!$conn2-&gt;error) {
              echo "Errormessage: $conn-&gt;error";
      }
          echo $now;
  
  
  
      }
  
  
  
      echo "&lt;/form&gt;";
  
  
  
  
  
      echo "&lt;/body&gt;";
      echo "&lt;/html&gt;";
      ?&gt;
  </code></pre>