• thinkphp3.2 分页的实现


    控制器中的代码:
     

    $db = M("cost");

    $where = "查询条件";
    $count = $db->where($where)->count();
    $pagecount = 20;
    $page = new ThinkPage($count , $pagecount);
    $page->parameter = $row; //此处的row是数组,为了传递查询条件
    $page->setConfig('first','首页');
    $page->setConfig('prev','上一页');
    $page->setConfig('next','下一页');
    $page->setConfig('last','尾页');
    $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% 第 '.I('p',1).' 页/共 %TOTAL_PAGE% 页 ( '.$pagecount.' 条/页 共 %TOTAL_ROW% 条)');
    $show = $page->show();
    $list = $db->where($where)->order('id desc')->limit($page->firstRow.','.$page->listRows)->select();
    $this->assign('list',$list);
    $this->assign('page',$show);
    $this->display();
     
    模版中调用代码:
     
    <div class="pagelist">{$page}</div>
     
    附带分页样式:
     
    .pagelist{ text-align:center; background:#f1f1f1; padding:7px 0;}
    .pagelist a{ margin:0 5px; border:#6185a2 solid 1px; display:inline-block; padding:2px 6px 1px; line-height:16px; background:#fff; color:#6185a2;}
    .pagelist span{ margin:0 5px; border:#6185a2 solid 1px; display:inline-block; padding:2px 6px 1px; line-height:16px; color:#6185a2; color:#fff; background:#6185a2;}
  • 相关阅读:
    关于树状数组区间最值
    Gym 100500B
    RQNOJ Bus
    关于加权的LIS问题
    vs tip1
    小常识
    我的魔方主力
    killer驱动
    从日升的mecha anime看mecha genre的衰退
    关于供给移动端的视频压制
  • 原文地址:https://www.cnblogs.com/zhongshenggen/p/5981603.html
Copyright © 2020-2023  润新知