Я хочу, чтобы отобразить список продуктов, но в выходном браузере этот код отображается только последний продукт и не обращая внимания на предыдущие пункты:Корзинка отображается только один пункт
<?php
$cartOutput="";
if(!isset($_SESSION["cart_array"])|| count($_SESSION["cart_array"])<1){
$cartOutput="<h2 align='center'>Your shopping cart is empty</h2>";
}else{
$i=0;
foreach($_SESSION["cart_array"] as $each_item){
$i++;
$cartOutput="<h2>Cart Item $i</h2>";
$cartOutput="Item ID:" .$each_item['item_id']."<br>";
$cartOutput="Item Quantity:" .$each_item['item_id']."<br>";
//while(list($key,$value)=each($each_item)){
//$cartOutput="item_id: $pid <br> $key: $value<br/>";
//}
}
}
?>
и здесь HTML
<body>
<div align="center" id="mainWrapper">
<?php include_once("template_header.php");?>
<div id="pageContent">
<div style="margin:24px; text-align:left;">
<?php echo $cartOutput ?>
<br /><br />
<a href="cart.php?cmd=emptycart">Click Here to Empty Your Shopping Cart</a>
</div>
<br />
</div>
<?php include_once("template_footer.php");?>
</div>
</body>
</html>
второе решение wokred отлично спасибо – user3306847