Using php and mysql-queries how can I produce HTML output in a YEAR-MONTH format.
I know we can use the MONTH() function if we want to sort it explicitly by month. But I want a both YEAR/MONTH sorting.
The table has an ID,DATA,TIME columns. I am able to output currently the YEAR/MONTH combination with a loop which just iterates from 1900 to 2100 and the sorting the rows in each of those year by month and displaying if we find any rows.
But this is naive approach and infact bad way to do it as its not modular.
How can I get a YEAR-MONTH wise sorting output in HTML using the TIME column’s data
Like the MySQL
MONTH()function, there is also aYEAR()function. Additionally, you can sort on multiple columns in a singleSELECTstatement and by doing so you will sort everything based on the first column, then sub-sort within each group.So, to get Year/Month sorting, you can use the following
ORDER BYclause: