grouping archive by year and month using php and mysql
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to create an archive list like this: 2014 March Feb Jan Post 1 Post 2 2013 November Post 1 I am using by PDO. the table I m using is having postDate as Datetime. postSlug is used to get a clean url. The coding I am using now is: <h1>Archives</h1> <hr /> <ul> <?php $stmt = $db->query("SELECT postTitle, Month(postDate) as Month, Year(postDate) as Year FROM blog_posts_seo ORDER BY postDate DESC"); while($row = $stmt->fetch()){ $posts = $row['postTitle']; $year = $row['Year']; $monthName = date("F", mktime(0, 0, 0, $row['Month'], 10));