时间:2021-07-21人气:-
<!--{eval $fids = '2,36,37,39';$recs=array();$query=DB::query("SELECT * FROM ".DB::table('forum_forumrecommend')." where fid in ($fids) order by `tid` desc limit 10");while($item=DB::fetch($query))$recs[]=$item;}--><!--{loop $recs $rec}--><li><a href="forum.php?mod=viewthread&tid=$rec['tid']">$rec['subject']</a><span class="pipe">|</span>作者<!--{$rec['author']}--></li><!--{/loop}-->调用来自版块2,36,37,39的推荐主题,按帖子tid倒序排列,取10篇。根据我的想法,想要每个版块只取1篇,总10篇。
那么代码:<!--{eval $fids = '2,36,37,39';$recs=array();$query=DB::query("SELECT fid,max(tid) as tid,subject,tid,author FROM ".DB::table('forum_forumrecommend')." where fid in ($fids) group by `fid` order by `tid` desc limit 10");while($item=DB::fetch($query))$recs[]=$item;}--><!--{loop $recs $rec}--><li><a href="forum.php?mod=viewthread&tid=$rec['tid']">$rec['subject']</a><span class="pipe">|</span>作者<!--{$rec['author']}--></li><!--{/loop}-->但是有个比较挫的问题,取一篇的时候,只能取最先推荐的。