Php outputs table content quickly and efficiently.

Source: Internet
Author: User
Php outputs table content quickly and efficiently. This post was last edited by phpcainiao at 12:03:08

Php outputs table content quickly and efficiently.

For example, I now have a test table.
There are IDs, fenlei, mc
Id, automatic growth,
Fenlei, participating regions
Mc, specific selection parameters
Id fenlei mc
1 Beijing health care
2 Shanghai health care
3. good service in Shanghai
4 Tianjin health care
5. good service in Tianjin
6. good service in Beijing
7 Shanghai health care
8. good service in Shanghai

I want to make a statistics on this table .. Use the program to output the following table.

I want to separate statistics



Reply to discussion (solution)

Csv

Csv

What do you mean, I want to output online,

These are the most basic statistics
Combine the array intersection, array_count_values, array_sum, and count.

These are the most basic statistics
Combine the array intersection, array_count_values, array_sum, and count.

Thank you for the case code ,.. Brother.

These are the most basic statistics
Combine the array intersection, array_count_values, array_sum, and count.

I am a newbie. please give me an example. thank you ..

You should give me an array first. I'm too lazy to type.

You should give me an array first. I'm too lazy to type.

Id fenlei mc
1 Beijing health care
2 Shanghai health care
3. good service in Shanghai
4 Tianjin health care
5. good service in Tianjin
6. good service in Beijing
7 Shanghai health care
8. good service in Shanghai


You should give me an array first. I'm too lazy to type.

Id fenlei mc
1 Beijing health care
2 Shanghai health care
3. good service in Shanghai
4 Tianjin health care
5. good service in Tianjin
6. good service in Beijing
7 Shanghai health care
8. good service in Shanghai

This is a beginner's Portal. please give me more advice.

This is called an array?

This is called an array?

I don't know if this is an array. The problem is that I gave you an array. how can I generate an array...
So, I want to see the process of generating numbers, the records of the data table I just gave.

I just gave a record of a data table, not an array. I am not very clear about how to use this table to generate an array ..
Thank you for taking the initiative.

I just gave a record of a data table, not an array. I am not very clear about how to use this table to generate an array ..
Thank you for taking the initiative.

Good code of online and other leaders. Thank you ..

select a.fenlei, count(*), count(*)/(select count(*) from test)*100 as percentage, constitutefrom test a, (select fenlei, group_concat(mc,',',cnt) as constitute from(select fenlei, mc, count(*) as cnt from test group by 1,2) t group by 1) t1where a.fenlei=t1.fenlei group by 1

Execute this SQL command to obtain such data
Array ([0] => Array ([fenlei] => BEIJING [count (*)] => 2 [percentage] => 25.0000 [constitute] => good service, 1, good hygiene, 1) [1] => Array ([fenlei] => Shanghai [count (*)] => 4 [percentage] => 50.0000 [constitute] => good service, 2, good hygiene, 2) [2] => Array ([fenlei] => Tianjin [count (*)] => 2 [percentage] => 25.0000 [constitute] => good service, 1, good hygiene, 1 ))
The constitute column must be processed during 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.