0
我剛開始使用PDO(喜歡它!)。仍在努力學習基礎知識。目前我可以建立連接並顯示我想要的數據。但是,我想根據日期顯示從最新到最舊的博客文章。以下是我正在使用的代碼:使用PDO訂購從最近到最早的博客文章
<?php
while($row = $sth->fetch()) { ?>
<ul class="blog article_list large">
<li>
<img class="img_frame" src="images/blog_large/post01.jpg" alt="" />
<article>
<h2><a href="#"><?php echo $row['title'] ?></a></h2>
<?php echo $row['slug'] ?>
<small class="details">
By <a href="#" class="article_author"><?php echo $row['author'] ?></a>
on <time datetime="2011-09-28" pubdate="pubdate"><?php echo date("m-d-Y", strtotime($row['date'])) ?></time>
in <a href="#" class="cat"><?php echo $row['category'] ?></a>.
</small>
</article>
</li>
</ul>
<?php } ?>
是否有PDO語句來執行此操作?
在此之前您正在運行的查詢中添加一個ORDER BY'子句 – 2012-03-07 19:29:29