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.