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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

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

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools