最新消息: 新版网站上线了!!!

php文章年份月份归档的做法

<?
$dbh = mysql_pconnect($db_host, $db_user, $db_pass);
mysql_select_db($db_name,$dbh);
$query=”SELECT COUNT(id) total, MONTHNAME(create_date) month, YEAR(create_date) year FROM news_en GROUP BY MONTH(create_date), YEAR(create_date) ORDER BY create_date”;
while($row = mysql_fetch_array($query)) {

foreach ($row as $month): ?>

<li>
<a href=”news.php?year=<? echo $month['year'] ?>&month=<? echo $month['month'] ?>”>
<?php echo $month['month'] . ” ” . $month['year'] .”(” . $month['total'] .”)” ?>
</a>
</li>

<? endforeach; } ?>

转载请注明:谷谷点程序 » php文章年份月份归档的做法