购物车主程序:cart.php:
nbsp;html>
订餐系统
products
query(select * from cart order by id asc);
if ($results) {
//fetch results set as object and output html
while($obj = $db->fetch_object($results))
{
echo '';
echo '';
echo 'product_img_name.'>
';
echo ''.$obj->product_name.'';
echo ''.$obj->product_desc.'
';
echo '';
echo 'price '.$currency.$obj->price.' | ';
echo 'qty ';
echo 'add to cart';
echo '
';
echo 'product_code.' />';
echo '';
echo '';
echo '';
echo '
';
}
}
?>
your shopping cart
提交按钮的链接,点按钮没反应。cart_update.php:
10){
die('this demo does not allowed more than 10 quantity!
back to products.
');
}
//mysqli query - get details of item from db using product code
$results = $mysqli->query(select product_name,price from cart where product_code='$product_code' limit 1);
$obj = $results->fetch_object();
if ($results) { //we have the product info
//prepare array for the session variable
$new_product = array(array('name'=>$obj->product_name, 'code'=>$product_code, 'qty'=>$product_qty, 'price'=>$obj->price));
if(isset($_session[products])) //if we have the session
{
$found = false; //set found item to false
foreach ($_session[products] as $cart_itm) //loop through session array
{
if($cart_itm[code] == $product_code){ //the item exist in array
$product[] = array('name'=>$cart_itm[name], 'code'=>$cart_itm[code], 'qty'=>$product_qty, 'price'=>$cart_itm[price]);
$found = true;
}else{
//item doesn't exist in the list, just retrive old info and prepare array for session var
$product[] = array('name'=>$cart_itm[name], 'code'=>$cart_itm[code], 'qty'=>$cart_itm[qty], 'price'=>$cart_itm[price]);
}
}
if($found == false) //we didn't find item in array
{
//add new user item in array
$_session[products] = array_merge($product, $new_product);
}else{
//found user item in array list, and increased the quantity
$_session[products] = $product;
}
}else{
//create a new session var if does not exist
$_session[products] = $new_product;
}
}
//redirect back to original page
header('location:'.$return_url);
}
//remove item from shopping cart
if(isset($_get[removep]) && isset($_get[return_url]) && isset($_session[products]))
{
$product_code = $_get[removep]; //get the product code to remove
$return_url = base64_decode($_get[return_url]); //get return url
foreach ($_session[products] as $cart_itm) //loop through session array var
{
if($cart_itm[code]!=$product_code){ //item does,t exist in the list
$product[] = array('name'=>$cart_itm[name], 'code'=>$cart_itm[code], 'qty'=>$cart_itm[qty], 'price'=>$cart_itm[price]);
}
//create a new product list for cart
$_session[products] = $product;
}
//redirect back to original page
header('location:'.$return_url);
}
?>
回复讨论(解决方案) 你的表单没有提交按钮,且没有给出通过 js 提交的代码
所以任何浏览器都不可能产生表单提交动作
你的表单没有提交按钮,且没有给出通过 js 提交的代码
所以任何浏览器都不可能产生表单提交动作
解决了,是submit的事
