title: Deleting selected item
body: <p>Good day. I want to delete selected item by the user. But it turns out what ever button clicked by user, the first data row is deleting. Im stuck here. Please help.</p>
  
  <p>This is my code:</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>    &lt;form  method="POST" action="&lt;?php $_PHP_SELF ?&gt;"&gt;
  &lt;?php
  
          $query = "select * from tblsr";
          $request = mysql_query($query)or die(mysql_error());?&gt;
          &lt;table class="table table-hover"&gt;
          &lt;tr&gt;    
                  &lt;th&gt;Softwares&lt;/th&gt;
                  &lt;th&gt;Difficulty&lt;/th&gt;
                  &lt;th&gt;&lt;/th&gt;
                  &lt;th&gt;&lt;/th&gt;
                  &lt;/tr&gt;
          &lt;?php while($row = mysql_fetch_array($request)){
          ?&gt;
          &lt;tbody&gt;
              &lt;tr class="success"&gt;
                  &lt;td&gt;&lt;?php echo $row['Software']; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $row['Difficulty']; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" class="btn btn-sm btn-success" name="change" value="Change Difficulty"/&gt;&lt;/td&gt;  
                  &lt;td&gt;&lt;input type="submit" class="btn btn-sm btn-danger" name="remove" value="Delete"/&gt;&lt;/td&gt;
                  &lt;input type="hidden" name="id[]" value="&lt;?php echo $row['id']; ?&gt;"/&gt;
              &lt;/tr&gt;
          &lt;/tbody&gt;
          &lt;?php
          }
  
  ?&gt;  &lt;/form&gt;
  </code></pre>
  
  <p><strong>DELETE Query</strong></p>
  
  <pre><code>if(isset($_POST['remove'])){
   $count = count($_POST['id']); //get total number of array element
  for ($i = 0; $i &lt; $count; $i++) {
  $id = $_POST['id'][$i];
          $sql = "Delete FROM tblsr 
                  Where id = '$id'";
  
              $success = mysql_query($sql) or die (mysql_error());
              mysql_close();  
  
              if ($success == TRUE){
  
              ?&gt;
                  &lt;script&gt;
                      alert('Deleted.');  
                      window.location.href='manageRequest.php';
                  &lt;/script&gt;
  
              &lt;?php
          }
  
  }
      }
  </code></pre>