How to handle data display processing

Source: Internet
Author: User
Data Display Processing XMLcode time period number of hosts 2012-02-0808ETC56-542N432012-02-0809ETC56-542N372012-02-0810ETC54-623N16 data display processing
XML code
  Time period machines quantity 2012-02-08 08 ETC56-542N 432012-02-08 09 ETC56-542N 372012-02-08 10 ETC54-623N 162012-02-08 10 ETC54-628N 22


How can this problem be solved?
XML code
  Time period ETC56-542N ETC54-623N ETC54-628N quantity total 08:00:00-09:00:00 43 4309: 00: 00-10:00:00 37 3710: 00: 00-11:00:00 16 22 38

SQL query statement:
SQL code
  SELECT DATE_FORMAT(`date`,'%Y-%m-%d %H') as time,type,count(*) as count FROM `barcode_2d` WHERE date >= '".$thisday2." 08:00:00' AND date < '".$thisday." 08:00:00' GROUP BY type , time ORDER BY date ASC




------ Solution --------------------
Yes, this is a cross tabulation. You can search "cross tabulation" to get the definition and algorithm of the cross tabulation.
When combined with databases, there are ready-made stored procedures that can be used. However, you may not be able to understand the algorithm because it is highly skillful.

The idea is simple when php is used only:
1. Save the query results in an array
2. process data to the required format
3. convert rows and columns of arrays
4. traverse the array and output

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.