title: PHP submit button while loop
body: <p>Hi guys im having a bit of a problem on how to get the value of the table row everytime i click an add button. what im trying to achieve is that to pass the value of the row to another php file for sql query. at the moment i have a table using a while loop and displaying a list of names from the database with a "ADD" button per row. When ever i click the add button regardless of which row i always get the value of the last row. can someone please point of on which part of the code i made a mistake?
  here is my code</p>
  
  <pre><code>&lt;form action="addFriend.php" method="post"&gt;     &lt;table class="table table-bordered"&gt;
        &lt;?php
        $i = 1;
        while($row = mysqli_fetch_array($records))
        { 
        ?&gt;
          &lt;tr&gt;
            &lt;td&gt;&lt;?php echo $i; ?&gt;&lt;/td&gt;
            &lt;td&gt;&lt;input type="text" name="addedUser" value="&lt;?php echo $row["username"]; ?&gt;" readonly&gt;&lt;/td&gt;
            &lt;td&gt;
  
              &lt;button type="submit" name="row_&lt;?php echo $i; ?&gt;" id="row_user" value="&lt;?php echo $row["username"]; ?&gt;" class="btn btn-info"&gt;ADD&lt;/button&gt;
              &lt;?php $i++; ?&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
  
        &lt;?php 
        }
        ?&gt;
      &lt;/table&gt;
      &lt;/form&gt;
  </code></pre>