帝国ECMS教程:上一篇下一篇标题图片调用代码
下面这段代码可以用在新闻模型上,上一篇下一篇是按新闻的时间(newstime字段)排序的
较新一篇:
1 <?php
2 $infoPreNext = $empire->fetch1("select * from {$dbtbpre}ecms_news where classid=$GLOBALS[navclassid] and checked=1 and newstime>$navinfor[newstime] order by newstime asc limit 1;");
3 if(empty($infoPreNext[id])){
4 echo "没有了";
5 }else{
6 echo "<a href='".sys_ReturnBqTitleLink($infoPreNext)."'><img src='".$infoPreNext[titlepic]."'></a>";
7 }
8 ?>
较早一篇:
1 <?php
2 $infoPreNext = $empire->fetch1("select * from {$dbtbpre}ecms_news where classid=$GLOBALS[navclassid] and checked=1 and newstime<$navinfor[newstime] order by newstime desc limit 1;");
3 if(empty($infoPreNext[id])){
4 echo "没有了";
5 }else{
6 echo "<a href='".sys_ReturnBqTitleLink($infoPreNext)."'><img src='".$infoPreNext[titlepic]."'></a>";
7 }
8 ?>