下面这段代码可以用在新闻模型上,上一篇下一篇是按新闻的时间(newstime字段)排序的
较新一篇: <?php $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;"); if(empty($infoPreNext[id])){ echo "没有了"; }else{ echo "<a href='".sys_ReturnBqTitleLink($infoPreNext)."'><img src='".$infoPreNext[titlepic]."'></a>"; } ?>
较早前一篇: <?php $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;"); if(empty($infoPreNext[id])){ echo "没有了"; }else{ echo "<a href='".sys_ReturnBqTitleLink($infoPreNext)."'><img src='".$infoPreNext[titlepic]."'></a>"; } ?>
|