Home Backend Development PHP Tutorial 数据显示处理,该怎么处理

数据显示处理,该怎么处理

Jun 13, 2016 am 10:06 AM
date etc quot

数据显示处理

XML code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->时间段            机种            数量        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                
Copy after login


如何处理能变成以下格式?
XML code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->时间段            ETC56-542N      ETC54-623N     ETC54-628N    数量合计                08:00:00-09:00:00    43                    4309:00:00-10:00:00    37                    3710:00:00-11:00:00            16          22        38
Copy after login

sql查询语句:
SQL code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->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 
Copy after login




------解决方案--------------------
是的,这种情况是交叉表。你可以搜索“交叉表”得到交叉表的定义和算法
当与数据库结合时,有现成的存储过程可以利用。不过算法的技巧性较高,您未必能看得懂

只用 php 实现时,思路很简单:
1、将查询结果保存于数组
2、加工数据到需要的格式
3、对数组做行列转换
4、遍历数组,输出
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to create and name a file/folder based on current timestamp How to create and name a file/folder based on current timestamp Apr 27, 2023 pm 11:07 PM

If you're looking for a way to automatically create and name files and folders based on system timestamps, you've come to the right place. There is a super simple way to accomplish this task. The created folders or files can then be used for various purposes such as storing file backups, sorting files based on date, etc. In this article, we will explain in some very simple steps how to automatically create files and folders in Windows 11/10 and name them according to the system’s timestamp. The method used is a batch script, which is very simple. Hope you enjoyed reading this article. Section 1: How to automatically create and name a folder based on the current timestamp of the system Step 1: First, navigate to the parent folder where you want to create the folder,

PHP Warning: date() expects parameter 2 to be long, string given solution PHP Warning: date() expects parameter 2 to be long, string given solution Jun 22, 2023 pm 08:03 PM

When developing using PHP programs, you often encounter some warning or error messages. Among them, one error message that may appear is: PHPWarning:date()expectsparameter2tobelong,stringgiven. The error message means: the second parameter of the function date() is expected to be a long integer (long), but what is actually passed to it is a string (string). So, we

How to let all users print specified prompt information when logging in in Linux How to let all users print specified prompt information when logging in in Linux Feb 19, 2024 pm 05:12 PM

In Linux systems, through configuration files and scripts, you can display specified prompt information when all users log in. Next, we will introduce several commonly used implementation methods. Method 1: Modify the /etc/issue file. Open the terminal and use a text editor (such as vi or nano) to edit the /etc/issue file with root permissions. sudovi/etc/issue Add the prompt message you want to display at the end of the file, for example: Welcome to MyLinuxSystem! Please beaware that all activities are monitored. Save and close the file. Now when the user logs in, the system will display /

How to get the millisecond representation of a date using the getTime() method of the Date class How to get the millisecond representation of a date using the getTime() method of the Date class Jul 24, 2023 am 11:42 AM

How to get millisecond representation of date using getTime() method of Date class In Java, Date class is a class used to represent date and time. It provides many useful methods to manipulate and obtain information about date objects. Among them, the getTime() method is an important method in the Date class, which can return the millisecond representation of the date object. Next, we will detail how to use this method to obtain the millisecond representation of a date, and provide corresponding code examples. Using the Date class

How to configure software mirror source in Ubuntu? How to configure software mirror source in Ubuntu? Feb 19, 2024 am 11:15 AM

Configuring software mirror sources is an effective way to increase download speeds and obtain software updates in Ubuntu. The following are the configuration steps: Open the terminal: On the Ubuntu desktop, press the Ctrl+Alt+T key combination to open the terminal. Back up the original software source configuration file (optional): If you want to keep the original software source configuration backup, you can execute the following command to back up the /etc/apt/sources.list file: sudocp/etc/apt/sources.list/ etc/apt/sources.list.backup Edit the software source configuration file: Use a text editor (such as nano or vi) to open the software source configuration file: sudonano

Introduction to methods and usage of using Date and SimpleDateFormat classes to process time in Java Introduction to methods and usage of using Date and SimpleDateFormat classes to process time in Java Apr 21, 2023 pm 03:01 PM

1. Introduction The Date class in the java.util package represents a specific time, accurate to milliseconds. If we want to use our Date class, then we must introduce our Date class. Writing the year directly into the Date class will not produce the correct result. Because Date in Java is calculated from 1900, so as long as you fill in the first parameter with the number of years since 1900, you will get the year you want. The month needs to be subtracted by 1, and the day can be inserted directly. This method is rarely used, and the second method is commonly used. This method is to convert a string that conforms to a specific format, such as yyyy-MM-dd, into Date type data. First, define an object of Date type Date

Is ETC worth holding for the long term? Is ETC coin worth investing in? Is ETC worth holding for the long term? Is ETC coin worth investing in? Feb 27, 2024 pm 08:58 PM

Is ETC worth holding for the long term? ETC (Ethereum Classic) is a cryptocurrency based on blockchain technology. It was born on July 20, 2016. It is a branch of the Ethereum blockchain. The origin of ETC can be traced back to the controversy over the Ethereum hard fork in the Ethereum community. Is ETC coin worth investing in? Whether ETC coin is worth investing in requires comprehensive consideration of the following factors: Technical advantages: ETC coin is based on Ethereum blockchain technology, has advantages such as smart contracts and programmability, and has broad application prospects in the field of decentralized application development. Community support: ETC currency has an active community, and community members are confident in the long-term development of ETC currency. Market demand: ETC currency has a relatively high popularity in the cryptocurrency market.

What currency is ETC? What currency is ETC? Mar 01, 2024 am 11:30 AM

ETC coin, the full name of Ethereum Classic, is a cryptocurrency generated after the hard fork of the original Ethereum blockchain in 2016.

See all articles