title: How to I identify the row the user selects in my table?
body: <p>I am producing a set of users from my <code>DB</code> in an <code>HTML table</code> using a <code>while loop</code>. The idea is that the user will select the 'add user' button and the a <code>query</code> is run to add that row to the relevant project. However I cannot work out how to tell the query which row of data to add. Any suggestions?</p>
  
  <pre><code>&lt;table width="100%" cellpadding="5" cellspacing="5" &gt;
              &lt;p&gt;&lt;strong&gt;Search Results:&lt;/strong&gt;&lt;/p&gt;
              &lt;tr&gt;
                &lt;td&gt;&lt;/td&gt;
                &lt;td&gt;&lt;strong&gt;First Name&lt;/strong&gt;&lt;/td&gt;
                &lt;td&gt;&lt;strong&gt;Last Name&lt;/strong&gt;&lt;/td&gt;
                &lt;td&gt;&lt;strong&gt;Job Role&lt;/strong&gt;&lt;/td&gt;
                &lt;td&gt;&lt;strong&gt;Skill(s)&lt;/strong&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;?php
                          if(isset($_POST['search'])){
  
                          if(@mysqli_num_rows($search_query)!=0){
                              do{ 
                              ?&gt;
  &lt;tr&gt;
                &lt;td&gt;
                &lt;form action="AddUserToProject.php?id=&lt;?php echo urlencode($Project); ?&gt;" method="post" id="addform"&gt;
                      &lt;input type="submit" name="adduser" value="&lt;?php echo htmlspecialchars($search_rs['UserID']); ?&gt;"/&gt;
                &lt;/form&gt;
                &lt;/td&gt;
                &lt;td&gt;&lt;?php echo $search_rs['Fname']; ?&gt;&lt;/td&gt;
                &lt;td&gt;&lt;?php echo $search_rs['Lname']; ?&gt;&lt;/td&gt;
                &lt;td&gt;&lt;?php echo $search_rs['JobRole']; ?&gt;&lt;/td&gt;
                &lt;td&gt;&lt;?php echo $search_rs['Description']; ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
              &lt;?php   
  
              } while ($search_rs=mysqli_fetch_assoc($search_query));
                            } else {
                                  echo "No results found";
                              }}
  
              if(isset($_POST['adduser']))
              {
                      $AddUserID = $search_rs['UserID'];
                      $AddProjectID = $Project;
  
                      $sql = $con-&gt;query("INSERT INTO userprojects 
                                      (UserID, ProjectID) 
                                      VALUES  
                                      ('$AddUserID', '$AddProjectID')") 
                                      or die(mysqli_error($con)); 
                              } 
                          ?&gt;
              &lt;/table&gt;
  </code></pre>
  
  <p>Search = my search field above.</p>