High decomposition difficulty: PHP queries MYSQL data and how the record set is specially displayed

Source: Internet
Author: User
High decomposition difficulty: PHP queries MYSQL data and how the record set is specially displayed! MYSQL has a commodity price Statistical Table. you can use PHP to query a commodity and display it on the webpage. the query result is as follows: the difficulty is how to display the commodity by year and month! It's hard for me to die, so I beg for the statement !, PHPcode ............ $ re high decomposition difficulties: PHP queries MYSQL data, how to display the record set in a special way!
MYSQL has a commodity price statistical table,


Query a product in PHP and display it on the webpage. the query result is as follows:




The difficulty is how to display data by year and month! It's hard for me, so I beg for the statement!

------ Solution --------------------
PHP code
................ $ Result = mysql_query ("select year (addtime) as y, group_concat (jiage) as str from table_name group by year (addtime );"); while ($ row = mysql_fetch_assoc ($ result) {echo ''; echo" $ row [y] "; foreach (explode (',', $ row [str]) as $ v) echo "$ v; echo '';}............
------ Solution --------------------
$ Result = mysql_query ("select year (add_date) as y, group_concat (yc_jiage) as str from jiagedata group by year (add_date);") or die (mysql_error ());

Post a prompt.
------ Solution --------------------
Run the command # What information is prompted after the 12th floor.

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.