TP框架实现分页及条件查询
Posted FTHeD
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TP框架实现分页及条件查询相关的知识,希望对你有一定的参考价值。
public function xianshi(){ $db = D("doc"); $tj = " 1=1 "; $title = ""; if(!empty($_GET["name"])){ $title = $_GET["name"]; $tj = " title like ‘%{$title}%‘"; } $arr = $db ->where($tj) ->page($_GET["p"],5) ->select(); $zts = $db ->where($tj) ->count(); $page = new Page($zts,5); $page->setConfig("prev","上一页"); $page->setConfig("next","下一页"); $pagelist = $page->show(); // dump($pagelist); $this->assign("pagelist",$pagelist); $this->assign("name",$title); $this->assign("arr",$arr); $this->show();
<body> <div id="quanbu" style="background-image:url(__PUBLIC__/Upload/cpbj.jpg)"> <div id="head"> <h1>交流</h1> <form action="__ACTION__" method="get"> <input type="text" name="name" value="{$name}" /> <input type="submit" value="查询" /> </form> </div> <div id="left" class="cl"></div> <div id="right" class="cl"> <div id="rt"> <foreach name="arr" item="v"> <div class="title bt"><a href="content/id/{$v.id}">{$v.id} {$v.title}</a></div> <div class="btn bt">{$v.create_time|date="Y-m-d H:i:s",###}{$v.user_id} </div> </foreach> </div> <div>{$pagelist}</div> </div> </div> </body>
TP框架里网页xianshi对应CONTROLLER里的显示方法。
以上是关于TP框架实现分页及条件查询的主要内容,如果未能解决你的问题,请参考以下文章