title: php mysql update database on button click
body: <p>as the title states I am trying to write a code that will update a boolean data in column (I called 'status') for a specific row. I used while loop in table to display the rows of new registered and where the status is NULL, I've put two buttons (accept, reject) each in td so they'll be displayed to each name, What I want is when the accept button clicked, it sets the status of its row in the table to 1, and when reject is clicked, same thing but sets 0 instead of 1.</p>
  
  <p>I've did a lot of research over this but hit a road block after road block, so I really hope your help in this, many thanks!</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;table id="sHold" style="border:none;"&gt;
  
  &lt;?php
      $conn = mysqli_connect('localhost', 'root', '', 'srs-db') or die('ERROR: Cannot Connect='.mysql_error($conn));
  
      function getStudent () {
          global $conn;
          $query = "SELECT * FROM student_table WHERE status IS NULL;";
          $result = mysqli_query($conn, $query);
  
          $i = 1;
  
          while ($row = mysqli_fetch_array($result)) {
              $sId = $row['student_id'];
              $sName = $row['student_name'];
  
              echo "&lt;tr id='sNew".$i."'&gt;";
              echo "&lt;td&gt;".$i." - &lt;/td&gt;";
              echo "&lt;td&gt;$sId&lt;/td&gt;";
              echo "&lt;td&gt;$sName&lt;/td&gt;";
              echo "&lt;td&gt;&lt;button name='sAcc".$i."'&gt;Accept&lt;/button&gt;&lt;/td&gt;";
              echo "&lt;td&gt;&lt;button name='sRej".$i."'&gt;Reject&lt;/button&gt;&lt;/td&gt;";
              echo "&lt;/tr&gt;";
  
              $i++;
          }
          if (isset($_POST['sAcc'.$i])) {
              $row['status'] = 1;
          }
      }
  
      getStudent();
  
  ?&gt;
  
  &lt;/table&gt;
  </code></pre>