I have a foreach loop to display images like so:
<? foreach ($fmx as $key): ?>
<li class="span3">
<div class="thumbnail">
<h5 class ="cv-img-header">FMX</h5>
<div class="cv-icon-eye">
<a href="#fmx" role = "button" class = "icon-eye-open" data-toggle="modal"> </a>
</div>
<img src="<?= site_url('/files/fmx/' .$id.'/'.$var.'/fmx/'. $key["file_name"]); ?>">
<div id="fmx" class="modal hide fade cv-img-modal" tabindex="-1" role="dialog" aria-labelledby="fmx" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>FMX</h3>
</div>
<div class="modal-body">
<p><img src="<?= site_url('/files/fmx/' .$id.'/'.$var.'/fmx/'. $key["file_name"]); ?>"></p>
</div>
<div class="modal-footer">
<button class="btn btn-primary cv-modal-btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
</div>
</li>
<? endforeach;?>
The images are all displayed in the thumbnail dic has they should be, however, when I click to open the modal window, the image is always the first element of the array(The modal opens a bigger view of the image). How can I have each modal image correspond with the thubnail image?
The array: Some elements have been cut out because I dont know how to format them here in a readable way.
array(22) {
[0]=>
array(1) {
["file_name"]=>
string(37) "e00f50e3b0cf9a96357f16761e10d7a9.jpeg"
}
[1]=>
array(1) {
["file_name"]=>
string(37) "e3f07180d4a01cca8021f0b31142840e.jpeg"
}
[2]=>
array(1) {
["file_name"]=>
string(37) "c52127da0a36d737da527c2c32f07b9d.jpeg"
}
[3]=>
array(1) {
["file_name"]=>
string(37) "1339aa888b253a50900e2e3c236b58f8.jpeg"
}