Home >Backend Development >PHP Tutorial >ThinkPHP where conditional paging example with variables, thinkphpwhere_PHP tutorial

ThinkPHP where conditional paging example with variables, thinkphpwhere_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:15:26913browse

ThinkPHP has variable where conditional paging example, thinkphpwhere

The example in this article describes the implementation method of where conditional paging with variables in ThinkPHP. Share it with everyone for your reference.

The main function codes are as follows:

Copy code The code is as follows:

$Form= D('Announcement');
import("ORG.Util.Page");
$count = $Form->count(); //Calculate the total number
$p = new Page ( $count, 5 );
$map = array();//Use index array or object as query condition. The condition effects of using object mode and array mode are the same and are interchangeable.
$map['user_id']=$_SESSION['loginUserId']; //
$list=$Form->limit($p->firstRow.','.$p->listRows)->order('announcement_id desc')->where($map)->findAll (); //How to write paging statements where directly use
//dump($Form->getLastSql()); //Print out the sql statement
$page = $p->show (); //Paging mapping

I hope this article will be helpful to everyone’s PHP programming design.

How to get the transfer variables of the previous page and the next page when thinkingphp is paginating? I want to attach the upper and lower page effects to the picture without using the original paging effect

public function index() {//Just change the style of the icon $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', '');//Previous page $page->setConfig('next', '');//Next page// $page-> setConfig('first', ''); // $page->setConfig('last', ''); $page->setConfig('theme', '%upPage% %downPage%');// Only display the upper and lower page options $this->assign('page', $page->show()); $this->assign('list', $list); $this->display(); }

In ThinkPHP, I added search conditions to paginate, and the results found were correct, but the results when clicking on the next page or pagination link were wrong

You can copy that code directly from the TP manual and there will be no errors

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/904924.htmlTechArticleThinkPHP where conditional paging with variables example, thinkphpwhere This example describes the implementation method of ThinkPHP where conditional paging with variables . Share it with everyone for your reference. Main functions...
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