我已经制作了一个简单的购物车,其中有一个div,将显示在拥有购买物品的悬停上。问题是每次我点击add to cart
按钮。它不会在实例中统计购物车物品。我需要做的就是自己刷新我的页面。任何建议或帮助将是可观的。页面刷新后count()函数更新php
代码
<div id="cartContainer">
<div id="cart">
<li style="color: #515151">
<img id="cart_img" src="images/cart.png">
Cart <span class='badge' id='comparison-count'>
<?php
if(isset($_SESSION['cart'])&& !empty($_SESSION['cart'])&& count($_SESSION['cart'])>0)
{
echo count($_SESSION['cart']);
}
else {
$cart_count=0;
echo $cart_count;
}
?>
</span>
</li>
<div id="sidebar">
<?php
if(isset($_SESSION['cart'])&& !empty($_SESSION['cart'])){
?>
<table id="s_table">
<?php
foreach($_SESSION['cart'] as $id => $value){
//here it shows the item details
}
?>
</table>
</div>
</div>
</div>
添加无缓存头? – developerwjk
@developerwjk它将如何帮助我? – tabia
服务器脚本不会在前端悬停时运行。 –