title: Button to delete row from table - PHP SQL
body: <p>I have a web page that outputs data from my sql database. Each row has a delete button that should delete the data in this particular row. I am having a issue where when I click the delete button it always deletes the row with the first/lowest ID regardless of which button I click. It doesnt delete the row I want it to delete. Here is my code:
  HTML</p>
  
  <pre><code>&lt;form action="process.php" method="post"&gt;
  &lt;?php
  $sql = "
      SELECT *
        FROM playerTeam
  ";
  $result = mysqli_query($connection, $sql);
  ?&gt;      
  &lt;table&gt;
      &lt;?php
      if (mysqli_num_rows($result) &gt; 0) {
           while ($row = mysqli_fetch_assoc($result)) { ?&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;input type="text" name="id" value="&lt;?php echo $row['id']?&gt;"&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="fName[]" value="&lt;?php echo $row['firstName']?&gt;"&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="sName[]" value="&lt;?php echo $row['surName']?&gt;"&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="text" name="team[]" value="&lt;?php echo $row['team']?&gt;"&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" name="delete" value="Delete"&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;input type="submit" name="update" value="Update"&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;?php
          }
      } 
      ?&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>process.php</p>
  
  <pre><code>if (isset($_POST['delete'])) {
      $id = $_POST['id'];
      $sql = "DELETE FROM playerTeam WHERE id='$id'";
  
      if (mysqli_query($connection, $sql)) {
          echo "Record deleted";
      } else {
          echo "Error: " . $sql . "&lt;br&gt;" . mysqli_error($connection);
      }
  }
  </code></pre>
  
  <p>please could someone help me. Thanks</p>