我想按月份和年份分组显示它们,如下所示:
<p>
<div>August 2009</div>
<div class="fav">title 1</div>
<div class="fav">title 5</div>
<div class="fav">title 6</div>
etc...
</p>
<p>
<div>July 2009</div>
<div class="fav">title 3</div>
<div class="fav">title 8</div>
<div class="fav">title 9</div>
etc...
</p>
这是我的查询...
$fav = mysql_query("SELECT * FROM links WHERE user_id='{$row['id']}' GROUP BY post_id ORDER BY id DESC");
$TMPL = array (); $skin = new skin('mylinks/my'); $profile = '';
while($myfav = mysql_fetch_array($fav))
{
$favs = mysql_query("SELECT * FROM imdb WHERE id='{$myfav['post_id']}' LIMIT 100");
while($myfavs = mysql_fetch_array($favs))
{
$TMPL['profiles'] = '<div class="fav"><a href="/movie/'.$myfavs['id'].'"><img src="/'.$myfavs['poster'].'" title="Posted '.$myfavs['date'].'" /></a></div>';
$profile .= $skin->make();
}
}
我将如何对它们进行分组,然后循环显示如上?
任何帮助将不胜感激。