Home > Backend Development > PHP Tutorial > thinkphp实现上一篇与下一篇的方法_PHP

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

WBOY
Release: 2016-05-31 18:15:40
Original
776 people have browsed it

本文实例讲述了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程序设计有所帮助。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template