In the process of developing a set of mall systems, each product defines an age group, such as: 1,2,3,4,5 total of 5.
The goods_id number has been obtained from the shopping cart.
Now the demand is when the shopping cart goods, there are 2 age groups (here means: 1-5, in the middle with 2). That settlement is 95 percent.
When there are 3 age groups (similarly, 1-5, there are 3 age groups), then it is 90 percent.
One thing to note: Take 2 or 3, but not repeat, for example: There are 2 age groups in the shopping cart 1, which 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 field goods_age in the commodity Table (goods) of the database, which is the upper (1,2,3,4,5) Age segment.
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 do this by grouping each age group of statistics groups.
Ecshop Open Source System
Your so-called age is supposed to be type=1,2,3,4,5. The idea should be the group by type to get the query results, to see how many records are the number of type: How many dozen to match again. Not hard.