<script>
$(document).ready(function() {
$(".modal-name").on("click", function() {
$("#modal-name").html($(this).data("name"));
$("#modal-description").html($(this).data("description"));
$("#modal-attr1").html($(this).data("attr1"));
$("#modal-attr2").html($(this).data("attr2"));
$("#modal-art").html($(this).data("art"));
let images=JSON.parse($(this).attr('data-img'));
$('.carousel__slide').empty();
$.each(images, function( i, val ) {
$('#mainCarousel .carousel__track').append(`<div class="carousel__slide" data-src="${val}" data-fancybox="gallery"><img src='${val}'></div>`);
$('#thumbCarousel .carousel__track').append(`<div class="carousel__slide" data-src="${val}"><img class='panzoom__content' src='${val}'></div>`);
});
});
});
</script>
if (isset($_GET['id'])) {
$id = intval($_GET['id']);
$sth = $dbh->prepare("SELECT * FROM `catalog` WHERE `id` = :id ORDER BY `date_add` DESC");
$sth->bindParam('id', $id, PDO::PARAM_INT);
$sth->execute();
$items = $sth->fetchAll(PDO::FETCH_ASSOC);
}
else {
$sth = $dbh->prepare("SELECT * FROM `catalog` ORDER BY `date_add` DESC");
$sth->execute();
$items = $sth->fetchAll(PDO::FETCH_ASSOC);
}
if (!empty($items)) {
<a href="#modal-order" data-toggle="modal" data-img="
<?php if (!empty($images)): ?>
<?php foreach($images as $img): ?>
<?php
$name = pathinfo($img['filename'], PATHINFO_FILENAME);
$ext = pathinfo($img['filename'], PATHINFO_EXTENSION);
?>
/uploads/<?php echo $img['filename']; ?>
<?php endforeach; ?>
<?php endif; ?> " class="modal-name"><div class='btn-more'>Подробнее</div>
</a>
$json = trim(file_get_contents('https://card.wb.ru/cards/detail?spp=18®ions=68,64,83,4,38,80,33,70,82,86,75,30,69,22,66,31,48,1,40,71&pricemarginCoeff=1.0®=1&appType=1&emp=0&locale=ru&lang=ru&curr=rub&couponsGeo=12,3,18,15,21&dest=-1029256,-102269,-1278703,-1255563&nm=110383570'));
$data = json_decode($json,true);
echo $data[0]['qty'];
Array(3) [ "/uploads/1655046147-3832192997.jpg", "/uploads/1655046147-551899804.jpg", "/uploads/1655046147-2827771717.jpg" ]
есть массив с путями, нужно пробежать по этому массиву, добавить в модалку все картинки <img id="modal-img">