这是我的Vishnu代码版本:
使用 PHP 和 MYSQL
// first, select all the different dates
////////////////////////////////////////
$query = mysql_query( "SELECT DISTINCT Date_added FROM table_name" );
// now fetch the results from the mysql query (above)
while( $row = mysql_fetch_array($query) ){
// put the dates into a variable i.e. $date
$date = $row['Date_added'];
// now one can format the date to output like: "September 20th '13"
$date_string = date('F js \'y', strtotime('' .$date. ''));
// display the formatted date
echo "<h2>" .$date_string. "</h2>";
有关日期操作的更多信息
// Second, query the database for all items pertaining to each date (no foreach
// statement required)
///////////////////////////////////////////////////////////////////////////////
$cmd = mysql_query( "SELECT * FROM table_name WHERE Date_added='$date'" );
// now fetch the results from the mysql query (above)
while( $row = mysql_fetch_array($cmd) ){
// put the items into a variable i.e. $item
$item = $row['Item_name'];
// display the results
// note: one can also create a variable and echo that instead
echo "<p>" .$item. "</p><br/>";
}
}
// This code can be used to display anything by any category, not just by date
通过使用 CSS 可以使标签看起来很酷,希望你喜欢时间线。
如果您希望将日期导航应用程序的 PHP 代码添加到此,请投票。
对已弃用的代码表示歉意,将很快更新