Reputation: 63
I am having an issue where the modal is showing the same exact data every time, but my cards have updated correctly. I have the modal and cards contained in a foreach loop which goes through all the records in the events database. Can someone point me in the right direction? Thanks in advance.
*** Don't pay attention to the repeitiveness of the lists in the cards/modals. Im going to update the modal with the rest of the info after I find a fix.
<?php
foreach ($resultset as $record): ?>
<?php $string = $record['event_description'];?>
<div class = "col-md-4">
<div class="card-columns-fluid" style="width: 30rem;">
<img class="card-img-top" src='jumboHead.jpg' alt="Card image cap" height= "250px" width= "300px">
<ul class="list-group list-group-flush">
<li class="list-group-item"><b>Event: </b><?php echo $record['event_Name']; ?></li>
<li class="list-group-item"><b>Description: </b><?php echo charlimit($string, 50); ?></li>
<li class="list-group-item"><b>City/State: </b><?php echo $record['city']; ?> , <?php echo $record['event_state']; ?></li>
<li class="list-group-item"><b>Email: </b><?php echo $record['event_Email']; ?></li>
</ul>
<div class="card-body">
<!-- MODAL-->
<button type="button" class="btn btn-info btn-md" data-toggle="modal" data-target="#myModal">Open Event</button>
</div>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"><?php echo $record['event_Name']; ?></h4>
</div>
<div class="modal-body">
<ul class="list-group list-group-flush">
<li class="list-group-item"><b>Event: </b><?php echo $record['event_Name']; ?></li>
<li class="list-group-item"><b>Description: </b><?php echo $record['event_description']; ?></li>
<li class="list-group-item"><b>City/State: </b><?php echo $record['city']; ?> , <?php echo $record['event_state']; ?></li>
<li class="list-group-item"><b>Email: </b><?php echo $record['event_Email']; ?></li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</br>
</div>
<?php endforeach;?>
Upvotes: 0
Views: 695
Reputation: 1182
Well, there might be a problem because you are making a dynamic list of modals, and all the modals have the same id, that is #myModal.
So i dont know how you are triggering the modal show, but if you are doing something like $('#myModal').show(), you are seeing always the same information because you are hitting always the same modal. You could set and id based on each $record.
Upvotes: 2