Development of the mall system, problems encountered

Source: Internet
Author: User
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.

  • 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.