search
Homephp教程php手册ThinkPHP有变量的where条件分页实例,thinkphpwhere

ThinkPHP有变量的where条件分页实例,thinkphpwhere

本文实例讲述了ThinkPHP有变量的where条件分页的实现方法。分享给大家供大家参考。

主要功能代码如下:

复制代码 代码如下:


$Form= D('Announcement');
import("ORG.Util.Page");
$count = $Form->count();    //计算总数
$p = new Page ( $count, 5 );
$map = array();// 使用索引数组或者对象来作为查询条件,使用对象方式和使用数组方式的条件效果是相同的,并且是可以互换的。
$map['user_id']=$_SESSION['loginUserId'];  //
$list=$Form->limit($p->firstRow.','.$p->listRows)->order('announcement_id desc')->where($map)->findAll();  //分页语句写法  where直接运用
//dump($Form->getLastSql()); //打印出sql语句
$page = $p->show ();        //分页映射

希望本文所述对大家的PHP程序设计有所帮助。

thinkphp分页时 怎取得 上一页下一页的传递变量 就是我想不用原来的分页效果 把上下页效果附到图片上

public function index() {//把图标改一下样式就可以了 $user = M('User'); import('ORG.Util.Page'); $count = $user->count(); $listRows = 5; $page = new Page($count, $listRows); $list = $user->limit("{$page->firstRow},{$page->listRows}")->select(); $page->setConfig('prev', 'ThinkPHP有变量的where条件分页实例,thinkphpwhere');//上一页 $page->setConfig('next', 'ThinkPHP有变量的where条件分页实例,thinkphpwhere');//下一页 // $page->setConfig('first', ''); // $page->setConfig('last', ''); $page->setConfig('theme', '%upPage% %downPage%');//只显示上下页选项 $this->assign('page', $page->show()); $this->assign('list', $list); $this->display();}
 

ThinkPHP中我的加上搜索条件分页,查到的结果正确,但是点击下一页或者分页的链接结果不对

你在tp的手册上直接复制 那段代码 就不会出错
 

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor