首页 > 代码库 > thinkphp 3.2之分页

thinkphp 3.2之分页

控制器中代码:

 1        $demo=D(‘demo‘);
 2             $count= $demo->count();
 3             $Page= new \Think\Page($count,9);
 4             $Page->setConfig(‘header‘, ‘‘);
 5             $Page->setConfig(‘prev‘,‘上页‘);
 6             $Page->setConfig(‘next‘,‘下页‘);
 7             $Page->setConfig(‘first‘,‘首页‘);
 8             $Page->setConfig(‘last‘,‘末页‘);
 9             // $Page->setConfig(‘theme‘, ‘%FIRST%%UP_PAGE%%LINK_PAGE%%DOWN_PAGE%%END%%HEADER%‘);        
10             $show       = $Page->show();
11             $list = $demo->order(‘id‘)->limit($Page->firstRow.‘,‘.$Page->listRows)->select();
12             $this->assign(‘list‘,$list);
13             $this->assign(‘page‘,$show);
14             $this->display();

模板代码:

<div class="newslist">
    <ul>
        <foreach name="list" item="it">
            <li>
            <a href="http://www.mamicode.com/__URL__/newsshow/id/{$it.id}">{$it.title}</a></li>
        </foreach>                    
    </ul>
            
</div>        
<div class="page">
        {$page}
</div>

 

thinkphp 3.2之分页