i would like to pass a variable through a for loop into a link such that the loaded page passes information about the correct link. right now my code seems to be storing the last variable in the for loop and passing that onto the link. it means that the generated table in the link always references the final piece.
the code is:
<?php foreach($result as $key => $result) :?>
<?php session_regenerate_id(); $_SESSION['id'] = $result['id']; ?>
<tr>
<td><?php echo $result['id'] ?></td>
<td><?php echo $result['date'] ?></td>
<td><?php echo $result['name'] ?></td>
<td><div class="btn-group" data-toggle="buttons"><a href="cpt.php?id=$_SESSION['id']" target="_blank" class="btn btn-warning btn-xs" rel="noopener">More details</a></div></td>
</tr>
<?php endforeach;?>
The point is the link should display more information about the id that the user clicks on. However it only ever shows data of the last id. I think this is because the $_session['id'] is just storing the final loop.