Home  >  Article  >  Backend Development  >  thinkphp method to implement the previous article and the next article, thinkphp previous article_PHP tutorial

thinkphp method to implement the previous article and the next article, thinkphp previous article_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:12:101671browse

How thinkphp implements the previous and next articles, thinkphp previous article

The example in this article describes how thinkphp implements the previous and next articles. Share it with everyone for your reference. The specific implementation method is as follows:

Method 1:

Copy code The code is as follows:

//Previous article
$front=$Article->where("id<".$id)->order('id desc')->limit('1')->find();
$this->assign('front',$front);
//Next article
$after=$Article->where("id>".$id)->order('id desc')->limit('1')->find();
$this->assign('after',$after);

Method 2:

Copy code The code is as follows:
//Previous article
$front=$Classroom->where("nid<".$nid)->order('nid desc')->limit('1')->find();
$f=!$front?'No more':'.__URL__.'/nid/'.$front['nid'].'">'.$front['title'].'';
$this->assign('front',$f);
//Next article
$after=$Classroom->where("nid>".$nid)->order('nid desc')->limit('1')->find();
$a=!$after?'No more':'.__URL__.'/nid/'.$after['nid'].'">'.$after['title'].'';
$this->assign('after',$a);

I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/923902.htmlTechArticlethinkphp implements the previous and next articles, thinkphp previous article This article describes the example of thinkphp implementing the previous article The method of one article and the next. Share it with everyone for your reference. Specific implementation method...
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