//php实现上一篇、下一篇 获取当前浏览文章id $id = isset($_GET['id']) > ? intval($_GET['id']) : ""; 下一篇文章 $query = mysql_query("SELECT id,title FROM article WHERE id>'$id' ORDER BY id ASC LIMIT 1");
$next = mysql_fetch_array($query); 上一篇文章 $query = mysql_query("SELECT id,title FROM article WHERE id <'$id' ORDER BY id DESC LIMIT 1");
$prev = mysql_fetch_array($query); 页面显示上一篇和下一篇文章标题和链接 <div class="page_nav clearfix">
<div title="下一篇" class="next_page">
<a href="?id=<?php echo $next['id']; ?>"><?php echo $next['title']; ?></a>
</div>
<div title="上一篇" class="pre_page">
<a href="?id=<?php echo $prev['id']; ?>"><?php echo $prev['title']; ?></a>
</div>
</div>
<?php
//基于thinkPHP框架
$up = M('Content')->where(array('id' => array('gt',$id),'del'=>1,'cid'=>$cont['cid']))
->order('id asc')->find();
$this -> assign('up',$up);//上一篇 $dw = M('Content')->where(array('id' => array('lt',$id),'del'=>1,'cid'=>$cont['cid']))
->order('id desc')->find();
$this -> assign('dw',$dw);//下一篇
?>