1
Well, here’s the problem:
I have the following code HTML/PHP
which allows me to retrieve the last four data entered in the database 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 everything works perfectly. But as you can see in the code when clicking on the tag name image showDescr
supposedly appears a modal that will show the product description.
The problem is that I cannot the following modal code within the cycle while
otherwise it will show all the results at the same time (in supbreposição) and outside will show only one. The modal code is following:
<!-- 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 -->
Will I have to give a different name to the image that when clicking will appear the modal in the example tag name:
name="<?php echo $idProd ?>"
How are you loading the modal ? Only with link or ajax ?
– Hugo Alves
With the use of data target, bootstrap
– Adriano Maia