码迷,mamicode.com
首页 > 其他好文 > 详细

TP框架实现分页及条件查询

时间:2018-04-10 10:51:09      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:条件   orm   方法   NPU   style   网页   body   new   lis   

    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框架实现分页及条件查询

标签:条件   orm   方法   NPU   style   网页   body   new   lis   

原文地址:https://www.cnblogs.com/forqiwen/p/8776233.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!