我正在做一個像購物車一樣的小項目。 當我點擊此鏈接:如何使用php自我並將信息傳遞到其他頁面
echo "<td><a href=\"$_SERVER[PHP_SELF]?action=zero&commitbuy.php?ids=$id&qoh=$qtyhand&qtb=$quantity\">ok</a></td>";
我希望該程序執行的操作零,這將車表中刪除該產品,當我點擊確定鏈接:
<?php
$product_id = $_GET['id'];
$action = $_GET['action'];
if($product_id && !productExists($product_id)) {
die("Error. Product Doesn't Exist");
}
switch($action) {
case "add":
$_SESSION['cart'][$product_id]++;
break;
case "remove":
$_SESSION['cart'][$product_id]--;
if($_SESSION['cart'][$product_id] == 0) unset($_SESSION['cart'][$product_id]);
break;
case "zero":
$_SESSION['cart'][$product_id]==0;
break;
case "empty":
unset($_SESSION['cart']);
break;
}
?>
隨後也,commitbuy.php會更新某個產品的數量。 你能提出什麼建議,我會這樣做。它似乎沒有工作。當我將此代碼添加:
$_SERVER[PHP_SELF]?action=zero
這一個:
echo "<td><a href=\"commitbuy.php?ids=$id&qoh=$qtyhand&qtb=$quantity\">ok</a></td>";
什麼是在生產的HTML中的零動作鏈接? – 2011-04-15 20:16:55