Home  >  Article  >  Backend Development  >  thinkphp实现上一篇与下一篇的方法_php实例

thinkphp实现上一篇与下一篇的方法_php实例

WBOY
WBOYOriginal
2016-06-07 17:14:49891browse

本文实例讲述了thinkphp实现上一篇与下一篇的方法。分享给大家供大家参考。具体实现方法如下:

方法一:

复制代码 代码如下:

//上一篇 
$front=$Article->where("idorder('id desc')->limit('1')->find(); 
$this->assign('front',$front); 
//下一篇 
$after=$Article->where("id>".$id)->order('id desc')->limit('1')->find(); 
$this->assign('after',$after);

方法二:

复制代码 代码如下:
//上一篇 
$front=$Classroom->where("nidorder('nid desc')->limit('1')->find(); 
$f=!$front?'没有了':'.__URL__.'/nid/'.$front['nid'].'">'.$front['title'].''; 
$this->assign('front',$f); 
//下一篇 
$after=$Classroom->where("nid>".$nid)->order('nid desc')->limit('1')->find(); 
$a=!$after?'没有了':'.__URL__.'/nid/'.$after['nid'].'">'.$after['title'].''; 
$this->assign('after',$a);

更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《ThinkPHP入门教程》及《ThinkPHP常用方法总结》

希望本文所述对大家基于ThinkPHP框架的PHP程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn