欢迎使用CSDN-markdown编辑器

来源:互联网 发布:如何购买已备案域名 编辑:程序博客网 时间:2024/04/28 04:55
  1. Bootstrap
    a) Table 引用了’table-striped’, ‘table-hover’, ‘table-condensed’
    b) volist name=”list” id=”vo”
    c) 变量值用{$vo.xxxx} 获取标量的值
<div class="container-fluid">    <div class="table-responsive">        <table class="table table-striped table-hover table-condensed">        <thead>        <tr>            <th>            </th>            <th>            用户名            </th>            <th>            密码            </th>            <th>            电话号码            </th>            <th>            电子邮件            </th>            <th>            </th>            <th>            </th>        </tr>        </thead>        <tbody id="tbuser">        <volist name="list" id="vo">        <tr class="myclass">            <td>                <input type="checkbox" name="udCheck"/>            </td>            <td class="vousername">            {$vo.username}            </td>            <td class="vopassword">            {$vo.password}            </td>            <td class="vophone">            {$vo.phone}            </td>            <td class="voemail">            {$vo.email}            </td>            <td>                <a href='#' onclick="deleteUser('{$vo.userName}',this);" class="btn btn-danger btn-sm">删除</a>            </td>            <td>                <a class="edithere" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#example">编辑</a>            </td>            </volist>            </tbody>            </table>            <nav style="text-align:center;">            <ul class="pagination">                                     {$page}            </ul>            </nav>        </div>
  1. Thinkphp
    thinkphp 用了分页的方式来处理
<?php?>  $count= $user->count();// 查询满足要求的总记录数        $Page = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数(25)        //$Page->setConfig()设置样式        $Page->setConfig('prev',  'previous page');//上一页        $Page->setConfig('next',  'next page');//下一页        $Page->setConfig('first', 'First Page');//第一页        $Page->setConfig('last',  'End Page');//最后一页        //$Page->setConfig('theme','');设置你想显示的按钮,%XXXX%含义参照图示        $Page->setConfig ( 'theme', '当前%NOW_PAGE%/%TOTAL_PAGE%%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%' );        $show       = $Page->show();// 分页显示输出// 进行分页数据查询 注意limit方法的参数要使用Page类的属性        $list = $user->order('uid')->limit($Page->firstRow.','.$Page->listRows)->select();        // print_r($list);        $this->assign('list',$list);// 赋值数据集        $this->assign('page',$show);// 赋值分页输出        $this->display("profileau");        <?php 
  1. 修改后的page.class.php
<?php// +----------------------------------------------------------------------// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]// +----------------------------------------------------------------------// | Copyright (c) 2009 http://thinkphp.cn All rights reserved.// +----------------------------------------------------------------------// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )// +----------------------------------------------------------------------// | Author: liu21st <liu21st@gmail.com>// |         lanfengye <zibin_5257@163.com>// +----------------------------------------------------------------------class Page {    // 分页栏每页显示的页数    public $rollPage = 5;    // 页数跳转时要带的参数    public $parameter  ;    // 分页URL地址    public $url     =   '';    // 默认列表每页显示行数    public $listRows = 20;    // 起始行数    public $firstRow    ;    // 分页总页面数    protected $totalPages  ;    // 总行数    protected $totalRows  ;    // 当前页数    protected $nowPage    ;    // 分页的栏的总页数    protected $coolPages   ;    // 分页显示定制    protected $config  =    array('header'=>'条记录','prev'=>'上一页','next'=>'下一页','first'=>'第一页','last'=>'最后一页','theme'=>' <span style="font-size:18px; padding-top: 5px;height: 30px;padding-left: 5px;display: inline-block;">%totalRow% %header% %nowPage%/%totalPage% 页</span> %upPage% %downPage% %first%  %prePage%  %linkPage%  %nextPage% %end%');    protected $varPage;    /**     * 架构函数     * @access public     * @param array $totalRows  总的记录数     * @param array $listRows  每页显示记录数     * @param array $parameter  分页跳转的参数     */    public function __construct($totalRows,$listRows='',$parameter='',$url='') {        $this->totalRows    =   $totalRows;        $this->parameter    =   $parameter;        $this->varPage      =   C('VAR_PAGE') ? C('VAR_PAGE') : 'p' ;        if(!empty($listRows)) {            $this->listRows =   intval($listRows);        }        $this->totalPages   =   ceil($this->totalRows/$this->listRows);     //总页数        $this->coolPages    =   ceil($this->totalPages/$this->rollPage);        $this->nowPage      =   !empty($_GET[$this->varPage])?intval($_GET[$this->varPage]):1;        if(!empty($this->totalPages) && $this->nowPage>$this->totalPages) {            $this->nowPage  =   $this->totalPages;        }        $this->firstRow     =   $this->listRows*($this->nowPage-1);    }    public function setConfig($name,$value) {        if(isset($this->config[$name])) {            $this->config[$name]    =   $value;        }    }    /**     * 分页显示输出     * @access public     */    public function show() {        if(0 == $this->totalRows) return '';        $p              =   $this->varPage;        $nowCoolPage    =   ceil($this->nowPage/$this->rollPage);        // 分析分页参数        if($this->url){            $depr       =   C('URL_PATHINFO_DEPR');            $url        =   rtrim(U('/'.$this->url,'',false),$depr).$depr.'__PAGE__';        }else{            if($this->parameter && is_string($this->parameter)) {                parse_str($this->parameter,$parameter);            }elseif(empty($this->parameter)){                unset($_GET[C('VAR_URL_PARAMS')]);                if(empty($_GET)) {                    $parameter  =   array();                }else{                    $parameter  =   $_GET;                }            }            $parameter[$p]  =   '__PAGE__';            $url            =   U('',$parameter);        }        //上下翻页字符串        $upRow          =   $this->nowPage-1;        $downRow        =   $this->nowPage+1;        if ($upRow>0){            $upPage     =   "<li><li><a href='".str_replace('__PAGE__',$upRow,$url)."'>".$this->config['prev']."</a></li></li>";        }else{            $upPage     =   '';        }        if ($downRow <= $this->totalPages){            $downPage   =   "<li><li><a href='".str_replace('__PAGE__',$downRow,$url)."'>".$this->config['next']."</a></li></li>";        }else{            $downPage   =   '';        }        // << < > >>        if($nowCoolPage == 1){            $theFirst   =   '';            $prePage    =   '';        }else{            $preRow     =   $this->nowPage-$this->rollPage;            $prePage    =   "<li><li><a href='".str_replace('__PAGE__',$preRow,$url)."' >上".$this->rollPage."页</a></li></li>";            $theFirst   =   "<li><a href='".str_replace('__PAGE__',1,$url)."' >".$this->config['first']."</a></li>";        }        if($nowCoolPage == $this->coolPages){            $nextPage   =   '';            $theEnd     =   '';        }else{            $nextRow    =   $this->nowPage+$this->rollPage;            $theEndRow  =   $this->totalPages;            $nextPage   =   "<li><a href='".str_replace('__PAGE__',$nextRow,$url)."' >下".$this->rollPage."页</a></li>";            $theEnd     =   "<li><a href='".str_replace('__PAGE__',$theEndRow,$url)."' >".$this->config['last']."</a></li>";        }        // 1 2 3 4 5        $linkPage = "";        for($i=1;$i<=$this->rollPage;$i++){            $page       =   ($nowCoolPage-1)*$this->rollPage+$i;            if($page!=$this->nowPage){                if($page<=$this->totalPages){                    $linkPage .= "&nbsp;<li><a href='".str_replace('__PAGE__',$page,$url)."'>&nbsp;".$page."&nbsp;</a></li>";                }else{                    break;                }            }else{                if($this->totalPages != 1){                    $linkPage .= "&nbsp;<span class='current'>".$page."</span>";                }            }        }        $pageStr     =   str_replace(            array('%header%','%nowPage%','%totalRow%','%totalPage%','%upPage%','%downPage%','%first%','%prePage%','%linkPage%','%nextPage%','%end%'),            array($this->config['header'],$this->nowPage,$this->totalRows,$this->totalPages,$upPage,$downPage,$theFirst,$prePage,$linkPage,$nextPage,$theEnd),$this->config['theme']);        return $pageStr;    }}
0 0
原创粉丝点击