<?php
if(isset($_SESSION['cart'])){
$sql="SELECT * FROM products WHERE id IN (";
foreach($_SESSION['cart'] as $id => $value) {
$sql.=$id.",";
}
$sql=substr($sql, 0, -1).") ORDER BY name ASC";
echo $sql;
$query=mysqli_query($connect, $sql);
while($row=mysqli_fetch_array($query)){
?>
<p><?php echo $row['name'] ?> x <?php echo $_SESSION['cart'][$row['id_product']]['quantity'] ?></p>
<?php
}
?>
<hr />
<a href="index.php?page=cart">В корзину</a>
<?php
}else{
echo "<p>Корзина пуста.</p>";
}
?>