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

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

WBOY
Release: 2016-06-06 20:16:13
Original
1397 people have browsed it

这篇文章主要介绍了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程序设计有所帮助。

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template