我試圖爲我的新聞部分創建一個自動導航,到目前爲止,我一直很成功。那麼我說,但我碰到了一個障礙。PHP&MySql導航問題...隨着日期
我的導航自動創建一個鏈接到每個新聞故事這是很好,但我想要它做的是創建一個鏈接到它的月份。
這是我使用的代碼:
<li>January</li>
<li>February</li>
<li>March</li>
<li>April</li>
.....etc
:雖然我希望它看起來像這裏面吐出來,看起來像這樣
<li>January</li>
<li>February</li>
<li>March</li>
<li>March</li>
<li>March</li>
<li>April</li>
.....etc
無序列表
function pir_news_nav($nav_y) {
$mysql = mysqli_connect("HOST", "DB", "PW", "TABLE");
$newsQ = "SELECT * FROM tbl_news WHERE newsDateAdded LIKE '%". $nav_y ."%' AND newsActive=1 ORDER BY newsDateAdded ASC ";
$newsRes = mysqli_query($mysql, $newsQ);
while ($newsRow = mysqli_fetch_array($newsRes)) {
$newsTitle = $newsRow["newsTitle"];
$date = $newsRow["newsDateAdded"];
$y = date("Y", strtotime($date));
$m = date("m", strtotime($date));
$month = date("F", strtotime($date));
echo "<li><a href='?year=".$y."&month=".$m."'>".$month."</a></li>";
}
}
不,只是我發佈新聞報道的月份清單。沒有它重複。 – Martin 2011-01-31 16:12:14