title: Trying to build a delete button in PHP for each row but there's an error
body: <p>I was trying with the following code in PHP for generating row and delete button. But instead of deleting the selected ones, it deletes from the bottom of the row.</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php
  $connection = mysqli_connect('localhost','root','','rohit');
  {
  
      $query  = "SELECT * FROM user";
      $result = mysqli_query($connection,$query);
  
      while($row = mysqli_fetch_assoc($result)) {
          $id     = $row['id'];
          $name   = $row['name'];
          $lname  = $row['lname'];
          $dept   = $row['department'];
          $dob    = $row['DOB'];
          $doj    = $row['DOJ'];
          $mobile = $row['mobile'];
          $email  = $row['email'];
          $salary = $row['salary'];
          $gender = $row['gender'];
  
  
          echo "&lt;tr&gt;";
          echo "&lt;td&gt;{$id}&lt;/td&gt;";
          echo "&lt;td&gt;{$name}&lt;/td&gt;";
          echo "&lt;td&gt;{$lname}&lt;/td&gt;";
          echo "&lt;td&gt;{$dept}&lt;/td&gt;";
          echo "&lt;td&gt;{$dob}&lt;/td&gt;";
          echo "&lt;td&gt;{$doj}&lt;/td&gt;";
          echo "&lt;td&gt;{$mobile}&lt;/td&gt;";
          echo "&lt;td&gt;{$email}&lt;/td&gt;";
          echo "&lt;td&gt;{$salary}&lt;/td&gt;";
          echo "&lt;td&gt;{$gender}&lt;/td&gt;";
          echo '&lt;td&gt;' . '&lt;form method="post"&gt;&lt;button class="mb-1 mr-1 btn btn-primary" name="edit"&gt;&lt;i class="fa fa-edit"&gt;&lt;/i&gt;&lt;/button&gt;' .
              '&lt;button class="mb-1 mr-1 btn btn-danger" name="delete"&gt;&lt;i class="fa fa-times"&gt;&lt;/i&gt;&lt;/button&gt;&lt;/form&gt;'
              . '&lt;/td&gt;';
          echo "&lt;/tr&gt;";
  
      }
  }
  
  ?&gt;
  &lt;?php
  if (isset($_POST['delete'])) {
      $query1  = "DELETE FROM user ";
      $query1 .= "WHERE id = $id LIMIT 1";
      $result1 = mysqli_query($connection,$query1);
  
      if (!$result1) {
          die("FAILED" . mysqli_error($connection));
      }
  }
  ?&gt;
  
  </code></pre>
  
  <p>Any kind of help is appreaciated.
  Thanks in advance. :)</p>