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.
http://www.bkjia.com/PHPjc/923902.htmlwww.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...