title: Can only post first result of while loop
body: <p>I am using a while loop to display results from a query. The while loop is working fine. In hidden fields I would like to post the values of userID and accessID to the user details page. I am submitting the form using javascript to submit from a link. My problem is that regardless of the username I click I can only post the values for the first displayed record. What am I doing wrong?</p>
  
  <p>The code:</p>
  
  <pre><code>&lt;?php
  while($row = $result-&gt;fetch_array()) { ?&gt;
      &lt;form method="post" action="edit_user.php" id="userForm"&gt;
      &lt;tr&gt;
          &lt;td&gt;
              &lt;a href="#" onclick="return(submitForm())"&gt;&lt;?php echo $row['firstname'].' '.$row['surname']; ?&gt;&lt;/a&gt; 
              &lt;input type="hidden" name="userID" value="&lt;?php echo $row['userID']; ?&gt;" /&gt;
              &lt;input type="hidden" name="accessID" value="&lt;?php echo $row['accessID']; ?&gt;" /&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/form&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>The javascript used for submitting the form:</p>
  
  <pre><code>function submitForm() {
      var form = document.getElementById("userForm");
      form.submit();
  }
  </code></pre>
  
  <p>Thank you.
  EDIT - I don't want to pass the values in the url.</p>