Calculate the PHP code for displaying the content list based on the date. This post was last edited by ikaimi from 2014-12-3017: 03: 46 & lt ;? Php & nbsp; $ SQL & nbsp; mysql_query (select & nbsp; title, times & nbsp; from & nbsp; table calculates a piece of PHP code that displays the content list based on the delimiter of the date.
This post was last edited by ikaimi at 17:03:46
$ SQL = mysql_query ("select title, times from table order by times desc limit 0, 50 ");
While ($ row = mysql_fetch_array ($ SQL )){
// Display only once for each date
Echo "". $ row ['Times ']. "";
// All content released on this date
Echo"
". $ Row ['title']."";
}
?>
The display method is as follows:
12-30
Content 1 published on 12-30
12-30 release content 2
Content released from 12 to 30 3
Content released from 12 to 30 4
12-30 release content 5
12-29
Content 1 published on 12-29
12-29 released content 2
Content released on 12-29 3
Content released on 12-29 4
12-29 released content 5
12-28
Content 1 published on 12-29
12-29 released content 2
Content released on 12-29 3
Content released on 12-29 4
12-29 released content 5
------ Solution ----------------------
$ SQL = mysql_query ("select title, times from table order by times desc limit 0, 50 ");
$ Init_time = "";
While ($ row = mysql_fetch_array ($ SQL )){
If ($ init_time = '') {// The first cycle shows the time and the first information class.
$ Init_time = $ row ['Times '];
Echo "". $ row ['Times ']. "";
Echo"
". $ Row ['title']."";
} Else {// not the first to judge whether the time is equal to the previous one
If ($ init_time = $ row ['Times ']) {// if they are equal, the content is printed directly within the same period of time.
Echo "". $ row ['title']. "";
} Else {// different printing time and content
Echo "". $ row ['Times ']. "";
// All content released on this date
Echo"
". $ Row ['title']."";
}
}
}
?>
Based on your code, you can try it.