Well the problem is this:
I have the following code HTML/PHP
which allows me to go fetch the last four data entered in the database in order to show the last ones added:
$getLastFour = mysqli_query($dbc,"Select * From products Order By id_product DESC LIMIT 4") or die(mysqli_error($dbc));
while($row = mysqli_fetch_array($getLastFour)){
$idProd = $row["id_product"];
$name = $row["name_Product"];
$price = $row["prod_price"];
$description = $row["prod_description"];
?>
<div class="col-md-2">
<div class="grid">
<div class="portfolio app mix_all" data-cat="app" style="display: inline-block; opacity: 1;">
<div class="portfolio-wrapper">
<a data-toggle="modal" data-target=".bs-example-modal-md" href="#" class="b-link-stripe b-animate-go thickbox">
<img src="images/cont1.jpg"/>
<div class="b-wrapper"><h2 class="b-animate b-from-left b-delay03 ">
<img src="images/link-ico.png" class="img-responsive" name="showDescr" alt=""/></h2>
</div>
</a>
</div>
</div>
<p class="text-center image" style="color: #990000;"><b><u><?php echo $name ?></u></b></p>
<h2 class="text-center image"><b><?php echo $price.'€' ?></b></h2>
<p class="text-center button" ><a href="details.html">Comprar</a></p>
</div>
</div>
<?php
}
?>
So far so good, it works perfectly. But as you can see in the code when loading the tag name showDescr
image, a modal appears that will show the product description.
The problem is that I can not do the following modal code within the while
cycle, otherwise it will show all results at once (overlapping) and out will only show one. The modal code is as follows:
<!-- modal start -->
<a data-toggle="modal" data-target=".bs-example-modal-md" href="#"> </a>
<div class="modal fade bs-example-modal-md light-box" tabindex="-1" role="dialog"
aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-md">
<div class="modal-content light-box-info">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><img
src="images/close.png" title="close"/></button>
<h3>Descrição do Produto</h3>
<p><?php echo $description ?></p>
</div><!-- end modal content -->
</div><!-- end modal dialog -->
</div><!-- end modal fade -->
I have to give a different name to the image that when loading will appear the modal in the name tag example:
name="<?php echo $idProd ?>"