title: Updating user status using PHP and SQL
body: <p>Here, I'm trying to get a list of admin users and add and remove it using PHP and SQL.</p>
  
  <p>I listed some users but I couldn't think of removing and adding by updating a Boolean data (made this Boolean data to state them as valid or invalid) individually. </p>
  
  <p>Help from anyone would be highly appreciated.</p>
  
  <p>Thank you.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  // connection to database
  require 'config.php';
  
      $sql = "SELECT id, adminUser, password FROM admins WHERE legal = '1'";
      $result = mysqli_query($conn, $sql);
  
  
      $sql2 = "SELECT id, adminUser, password FROM admins WHERE legal = '0'";
      $result2 = mysqli_query($conn, $sql2);   
  
  ?&gt;
  
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;body class="w3-black"&gt;    
  
  &lt;!-- Page Content --&gt;
  &lt;div class="w3-padding-large" id="main"&gt;
    
  &lt;div class="w3-padding-64 w3-content w3-text-grey" id="contact"&gt;
    &lt;table&gt;
      &lt;tr&gt;
        &lt;th&gt;ID&lt;/th&gt;
        &lt;th&gt;Admin names&lt;/th&gt;
        &lt;th&gt;Status&lt;/th&gt;
        &lt;th&gt;Action&lt;/th&gt;
      &lt;/tr&gt;
  
      &lt;?php
        if (mysqli_num_rows($result) &gt; 0) {
            // output data of each row
            while($row = mysqli_fetch_assoc($result)) {
              
                echo "&lt;tr&gt;
                        &lt;td&gt;". $row["id"]. "&lt;/td&gt;
                        &lt;td&gt;". $row["adminUser"]. "&lt;/td&gt;
                        &lt;td&gt;valid&lt;/td&gt;
                        &lt;td&gt;&lt;a href='remove.php'&gt;remove&lt;/a&gt;&lt;/td&gt;
                      &lt;/tr&gt;" ;
            }
        }  
      ?&gt;
  
      &lt;?php
        if (mysqli_num_rows($result2) &gt; 0) {
            // output data of each row
            while($row2 = mysqli_fetch_assoc($result2)) {
              
                echo "&lt;tr&gt;
                        &lt;td&gt;". $row2["id"]. "&lt;/td&gt;
                        &lt;td&gt;". $row2["adminUser"]. "&lt;/td&gt;
                        &lt;td&gt;invalid&lt;/td&gt;
                        &lt;td&gt;&lt;a href='add.php'&gt;add&lt;/a&gt;&lt;/td&gt;
                      &lt;/tr&gt;" ;
            }
        }  
      ?&gt;
    &lt;/table&gt;
  &lt;/div&gt;
  
  &lt;div class="w3-padding-64 w3-content w3-text-grey" id="contact"&gt; 
    &lt;a href="adminpage.php"&gt;Go Back&lt;/a&gt;
  &lt;/div&gt;
  
    
  &lt;!-- END PAGE CONTENT --&gt;
  &lt;/div&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>