May I ask a related question?

Source: Internet
Author: User
Let's ask a question: cart. php & lt; on the shopping cart page ;? Phpdefine (ACCESE, 1); require (.. init. php); $ _ GET [gid] & nbsp; (int) $ _ GET [gid]; $ _ GET [num] & nbsp; (int) $ _ GET [num]; $ goo to ask a question
We are creating a shopping cart.
Cart. php on the shopping cart page

Define ('accesss', 1 );
Require ('../init. php ');

$ _ GET ['gid'] = (int) $ _ GET ['gid'];
$ _ GET ['num'] = (int) $ _ GET ['num'];

$ Goods = new goodsModel ();
$ Goods-> db ();
$ Cart = cart: getCart ();

Switch ($ _ GET ['AC']) {
// Add product
Case 'buy ':{
$ Result = $ goods-> select_goods ("g_id = $ _ GET [gid] and g_sale = 1 and g_del = 0 ");
$ G = $ goods-> db-> fetch_array ($ result );
// This product is available
If (! Empty ($ g) {// determines whether the product exists
If ($ g ['G _ no'] <$ _ GET ['num']) {// judge the inventory
$ Type = 'error ';
$ Msg = 'failed to add the item to the shopping cart (the inventory may be insufficient or the administrator swallowed it privately )';
Include (ROOT. 'View/home/tip.html ');
Exit;
}
// The product exists.
$ Cart-> addItem ("$ g [g_id]", "$ g [g_name]", "$ g [g_price]", "$ _ GET [num]"); // ---------------------- This row reports an error
} Else {
$ Type = 'error ';
$ Msg = 'failed to add it to the shopping cart (it may be dismounted, deleted, or swallowed by the administrator )';
Include (ROOT. 'View/home/tip.html ');
Exit;
}
Break;
}

}

$ Title = 'Shopping cart-mall system ';
$ Path = 'cart ';
Include (ROOT. 'View/home/cart.html ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.