I am trying to pass the column values from a single row generated from a while loop. When the link is clicked I want certain values from that row to be passed as hidden fields to another page.
The code:
<form id="repeat" name="repeat" action="edit_user.php" method="post">
<?php
$counter = 0;
while($row = $result->fetch_array()) {
$color = ($counter & 1)? "#D7ECEC" : "#DEDEDE";
$counter++;
?>
<tr align="left" valign="middle" style="background: <?php print $color; ?>">
<td><a href="#" onclick="document.getElementById('repeat').submit();" >
<?php echo $row['firstname']; ?> <?php echo $row['surname']; ?></a></td>
<td><?php echo $row['userlogin']; ?></td>
<td><?php echo $row['accesslvl']; ?></td>
<td ><?php echo $row['chgpasswrd']; ?></td>
</tr>
<input type="hidden" name="id" value="<?php echo $row['userID']; ?>" />
<input type="hidden" name="lvl" value="<?php echo $row['accesslvl']; ?>" />
<?php } ?>
</table>
</form>
What is happening is that the hidden fields are passing values for the last row of the while loop. Is it possible to do this so the hidden values being passed are from the same row of the link that is being clicked?
I've tried a few things and nothing works and I've not been able to find anything that directly relates to this problem. Any help would be appreciated. Cheers