设为首页收藏本站
查看: 166|回复: 0

[PHP] 一直超简单的php分页代码-支持smarty模板分页-PHP源码

[复制链接]

论坛元老

Rank: 6Rank: 6

积分
34274
主题
17031
UID
1347
M币
67
贡献
17176

  • 发表于 2018-7-16 21:27:00 | 显示全部楼层 |阅读模式
    param;
    unset($param['page']);
    if(is_array($param) && !empty($param)){
    foreach($param as $key=>$value){
    $data[] = $key."/".$value;
    }
    $this->url = implode("/",$data);
    $this->param = $this->url;
    $this->url = "/".$this->url;
    }else{
    if(!empty($param)){
    $this->url = $param;
    $this->param = $this->url;
    $this->url = "/".$this->url;
    }
    }
    }

    function pageDate(){
    $this->setParam();
    $num = ceil($this->lun/2);
    $this->page = intval($this->page);
    $this->page = $this->page page;

    $cpage['countPage'] = ceil($this->count/$this->size); //总页数
      $cpage['page'] = $this->page > $cpage['countPage'] ? $cpage['countPage']:$this->page ;
    //当前页
      //显示总数
    $cpage['lun'] = $cpage['countPage'] lun ? $cpage['countPage'] : $this->lun;
      //开始页码
    $cpage['start'] = $this->page > $num-1 ? $this->page-$num+1 : 1;

    $cpage['start'] = ($cpage['start']+$cpage['lun'])>=$cpage['countPage'] ? $cpage['countPage']-$cpage['lun']+1 : $cpage['start'];

    //参数显示
    $cpage['url'] = $this->url;
      //控制跳转
    $cpage['run'] = $this->run ? 1 : 0;
    $cpage['param'] = is_array($this->param) ? '': "?".$this->param;
    return $cpage;
    }
    }
      /*include "../inc/smarty.php";
    $cp = new page;

    empty($_REQUEST['page']) || $cp->page = $_REQUEST['page'];
    $cp->count = 70000;
    $cp->param = $_GET;
    $cp->size = 100;
    $cp->lun = 7;
    $cp->run = true;
    $data = $cp->pageDate();
    $smarty->assign("page",$data);
    $smarty->display("cpage.html");
    */
    ?>
    [/td] [/tr] [/table]
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    在我站开通SVIP可同时获得17个站点VIP资源 立即登录 立即注册
    快速回复 返回顶部 返回列表