Problems encountered when developing the mall system

Source: Internet
Author: User
When developing a mall system, problems encountered during the development of a mall system, each product defines a age group, such as: 1, 2, 4, 5, a total of 5.
The goods_id number has been obtained from the shopping cart.
The demand is that there are two age groups in the shopping cart (1-5, 2 in the middle). The settlement is 9.5 off.
If there are 3 age groups (similarly, between 1 and 5, there are 3 age groups), it is off.
One thing to note is: take 2 or 3, but they cannot be repeated. for example, if there are two age groups in the shopping cart, it is not discounted.

Code:

$ A = array (30, 31, 32, 33, 34); // The value in the array is the goods_id number of the item in the shopping cart. // There is a goods_age field in the database's commodity table (goods), that is, the (, 5) age group above.


Reply to discussion (solution)

$ A_str = implode ("','", $ a); $ res = mysql_query ("select goods_age from goods where goods_id in ('$ a_str') group by goods_age "); $ count = mysql_num_rows ($ res );

You can use the number of statistical groups for each age group.

Ecshop open source system

Your so-called age should be type = 1, 2, 3, 4, 5 .. The idea should be to get the query result by group by type, and check how many records are there and how many types are there. Not difficult.

Related Article

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.