PHP Variable Passing in Foreach on same page
- by tooly228
I've been struggling this for a while and I simply can't figure this out. Here is my code:
<?php
foreach($list as $id =>$name) {
echo("<td style=\"vertical-align:middle;\">
<a href=\"item=$id#confirm\" role=\"button\" data-toggle=\"modal\">
Buy</a></td></tr>");
}?>
<html>
<div class="modal small hide fade" id="confirm" tabindex="-1"
role="dialog" aria- labelledby="myModalLabel" aria-hidden="true">
<a href="redeem.php?item=<?php echo $id; ?>"><button class="btn btn-danger">
Buy</button></a></div>
The main issue here is that the $id from the foreeach is not the same as the $id in the div class link. Instead the link is the end value of the foreach list.