Home  >  Article  >  php教程  >  thinkphp实现上一篇与下一篇的方法,thinkphp上一篇

thinkphp实现上一篇与下一篇的方法,thinkphp上一篇

WBOY
WBOYOriginal
2016-06-13 09:19:22895browse

thinkphp实现上一篇与下一篇的方法,thinkphp上一篇

本文实例讲述了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框架的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