newsinfo.php里的代码
<?php
if($front['id']!=null){
$id = $front['id'];
echo "<a style='color:blue;' href='../id/$id'>上一条:$front[title]</a>";
}else{
echo "<a href='#'>上一条:没有了</a>";
}
echo " ";
if($after['id']!=null){
echo "<a style='color:blue;' href='../id/$after[id]'>下一条:$after[title]</a>";
}else{
echo "<a href='#'>下一条:没有了</a>";
}
?>
========
action里的代码
public function newsinfo(){
$this->info = M('info')->where("cid=18 and id=" . $_GET['id'])->find();
$this->front=M('info')->where("cid=18 and id<".$_GET['id'])->order('id desc')->limit('1')->find();
$this->after=M('info')->where("cid=18 and id>".$_GET['id'])->order('id desc')->limit('1')->find();
$this->display();
}
没有想象中的难么难得!