i'm newbie on this. I explain shortly what i need. Obtained the category ID via $_GET i want to print how images i have for each product (for that category).
For example, i have 2 product and 2 images for each product.
Problem found: with this code i have printed only the images for the first product and not for the second. Why? Thanks
$id=17;
$prod = "SELECT pd_id FROM product WHERE cat_id = ?";
$stmt = $con->prepare($prod);
$stmt->bindParam(1, $id);
$stmt->execute();
$num = $stmt->rowCount();
if($num>0)
{
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
extract($row);
$immagini = "SELECT pd_image FROM pd_images WHERE pd_id = ?";
$stmt = $con->prepare($immagini);
$stmt->bindParam(1, $pd_id);
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
extract($row);
?>
<img src="<?php echo $home_url; ?>images/product/<?php echo $pd_image; ?>" class="img-fluid border-radius-0" alt="">
<?php
}
}
}else { ?>
<div class="col-lg-12 text-center">
<h6>There's no products for this category</h6>
<i class="rt-icon2-user"></i>
<div class="divider-10 d-none d-xl-block"></div>
</div>
<?php } ?>