0
複選框不工作..我不能插入新的數據到表 有沒有發生,當我點擊「加入購物車」按鈕PHP - 數據不使用複選框未插入到表[更新]
有人可以幫我找出問題嗎?
<div class="carousel-inner">
<div class="item">
<ul class="thumbnails">
<?php
$query = mysql_query("SELECT * FROM product where pro_category='3' LIMIT 0,4 ");
while ($data = mysql_fetch_assoc($query)):
?>
<li class="span3">
<div class="product-box">
<span class="sale_tag"></span>
<?php echo '<p><a href="product_det.php?id='.$data['code'].'"><img src="admin/pro_image/'.$data['image'].'" /></a></p>'; ?>
<?php echo '<a href="product_det.php?id='.$data['code'].'" class="title">'.$data['name_nl'].'</a>'; ?>
<br/>
<td><input class='minuman' type='checkbox' name='add[]' value='<?php echo '<a class="btn btn-success" href="cart.php?add='.$data['code'].'" class="category">
</a>'; ?>'></td>
<p class="price"><?php echo 'RM '.$data['price']; ?></p>
</div>
</li>
<?php endwhile; ?>
</ul>
</div>
</div>
<ul class="thumbnails" align="center">
<div id="single_product" align="center">
<?php echo '<a class="btn btn-success" href="cart.php?add='.$data['code'].'" class="category">Add to Cart</a>'; ?>
</div>
</ul>
這是我插入車代碼:
if(isset($_GET['add'])){
$id = $_GET['add'];
$qt = mysql_query("SELECT code, quantity FROM product WHERE code='$id'");
while($qt_row = mysql_fetch_assoc($qt)){
if($qt_row['quantity'] != $_SESSION['cart_'.$_GET['add']] && $qt_row['quantity'] > 0){
$_SESSION['cart_'.$_GET['add']]+='1';
header("Location: keranjang.php");
} else {
echo '<script language="javascript">alert("Stok produk tidak mencukupi!"); document.location="index.php";</script>';
}
}
}
插入數據庫的php代碼在哪裏? –
['mysql'](http://php.net/manual/en/function.mysql-query.php)函數已棄用。使用['mysqli'](http://php.net/manual/en/mysqli.query.php)或PDO代替 – natanelg97
@u_mulder我已經更新了問題 – awang