• <em id="6vhwh"><rt id="6vhwh"></rt></em>

    <style id="6vhwh"></style>

    <style id="6vhwh"></style>
    1. <style id="6vhwh"></style>
        <sub id="6vhwh"><p id="6vhwh"></p></sub>
        <p id="6vhwh"></p>
          1. 国产亚洲欧洲av综合一区二区三区 ,色爱综合另类图片av,亚洲av免费成人在线,久久热在线视频精品视频,成在人线av无码免费,国产精品一区二区久久毛片,亚洲精品成人片在线观看精品字幕 ,久久亚洲精品成人av秋霞

            php分頁(php分頁代碼)

            更新時間:2023-03-02 08:01:41 閱讀: 評論:0

            各位朋友大家好!

            今天給大家帶來的是一款 供PHP初學者學習的分頁類庫

            分頁顯示模板,可用變量參數。當前選中的分頁鏈接模板,未選中的分頁鏈接模板。顯示文本設置,設置分頁模板, 設置選中分頁模板,設置未選中分頁模板。

            由于源碼比較長,想要文件版源碼的可以評論或者私聊小編!

            廢話不多說,上源碼!

            <?php

            /*

            * To change this template, choo Tools | Templates

            * and open the template in the editor.

            */

            /**

            * 分頁類

            * 使用方式:

            * $page = new Page();

            * $page->init(1000, 20);

            * $page->tNotActiveTemplate('<span> {a} </span>');

            * $page->tActiveTemplate('{a}');

            * echo $page->show();

            */

            class Page {

            /**

            * 總條數

            */

            private $total;

            /**

            * 每頁大小

            */

            private $pageSize;

            /**

            * 總頁數

            */

            private $pageNum;

            /**

            * 當前頁

            */

            private $page;

            /**

            * 地址

            */

            private $uri;

            /**

            * 分頁變量

            */

            private $pageParam;

            /**

            * LIMIT XX,XX

            */

            private $limit;

            /**

            * 數字分頁顯示

            */

            private $listnum = 8;

            /**

            * 分頁顯示模板

            * 可用變量參數

            * {total} 總數據條數

            * {pagesize} 每頁顯示條數

            * {start} 本頁開始條數

            * {end} 本頁結束條數

            * {pagenum} 共有多少頁

            * {frist} 首頁

            * {pre} 上一頁

            * {next} 下一頁

            * {last} 尾頁

            * {list} 數字分頁

            * {goto} 跳轉按鈕

            */

            private $template = '<div><span>共有{total}條數據</span><span>每頁顯示{pagesize}條數據</span>,<span>本頁{start}-{end}條數據</span><span>共有{pagenum}頁</span><ul>{frist}{pre}{list}{next}{last}{goto}</ul></div>';

            /**

            * 當前選中的分頁鏈接模板

            */

            private $activeTemplate = '<li class="active"><a href="javascript:;">{text}</a></li>';

            /**

            * 未選中的分頁鏈接模板

            */

            private $notActiveTemplate = '<li><a href="{url}">{text}</a></li>';

            /**

            * 顯示文本設置

            */

            private $config = array('frist' => '首頁', 'pre' => '上一頁', 'next' => '下一頁', 'last' => '尾頁');

            /**

            * 初始化

            * @param type $total 總條數

            * @param type $pageSize 每頁大小

            * @param type $param url附加參數

            * @param type $pageParam 分頁變量

            */

            public function init($total, $pageSize, $param = '', $pageParam = 'page') {

            $this->total = intval($total);

            $this->pageSize = intval($pageSize);

            $this->pageParam = $pageParam;

            $this->uri = $this->geturi($param);

            $this->pageNum = ceil($this->total / $this->pageSize);

            $this->page = $this->tPage();

            $this->limit = $this->tlimit();

            }

            /**

            * 設置分頁模板

            * @param type $template 模板配置

            */

            public function tTemplate($template) {

            $this->template = $template;

            }

            /**

            * 設置選中分頁模板

            * @param type $activeTemplate 模板配置

            */

            public function tActiveTemplate($activeTemplate) {

            $this->activeTemplate = $activeTemplate;

            }

            /**

            * 設置未選中分頁模板

            * @param type $notActiveTemplate 模板配置

            */

            public function tNotActiveTemplate($notActiveTemplate) {

            $this->notActiveTemplate = $notActiveTemplate;

            }

            /**

            * 返回分頁

            * @return type

            */

            public function show() {

            return str_ireplace(array(

            '{total}',

            '{pagesize}',

            '{start}',

            '{end}',

            '{pagenum}',

            '{frist}',

            '{pre}',

            '{next}',

            '{last}',

            '{list}',

            '{goto}',

            ), array(

            $this->total,

            $this->tPageSize(),

            $this->star(),

            $this->end(),

            $this->pageNum,

            $this->frist(),

            $this->prev(),

            $this->next(),

            $this->last(),

            $this->pagelist(),

            $this->gopage(),

            ), $this->template);

            }

            /**

            * 獲取limit起始數

            * @return type

            */

            public function getOfft() {

            return ($this->page - 1) * $this->pageSize;

            }

            /**

            * 設置LIMIT

            * @return type

            */

            private function tlimit() {

            return "limit " . ($this->page - 1) * $this->pageSize . ",{$this->pageSize}";

            }

            /**

            * 獲取limit

            * @param type $args

            * @return type

            */

            public function __get($args) {

            if ($args == "limit") {

            return $this->limit;

            } el {

            return null;

            }

            }

            /**

            * 初始化當前頁

            * @return int

            */

            private function tPage() {

            if (!empty($_GET[$this->pageParam])) {

            if ($_GET[$this->pageParam] > 0) {

            if ($_GET[$this->pageParam] > $this->pageNum)

            return $this->pageNum;

            el

            return $_GET[$this->pageParam];

            }

            }

            return 1;

            }

            /**

            * 初始化url

            * @param type $param

            * @return string

            */

            private function geturi($param) {

            $url = $_SERVER['REQUEST_URI'] . (strpos($_SERVER['REQUEST_URI'], "?") ? "" : "?") . $param;

            $par = par_url($url);

            if (ist($par["query"])) {

            par_str($par["query"], $params);

            unt($params["page"]);

            $url = $par["path"] . "?" . http_build_query($params);

            return $url;

            } el {

            return $url;

            }

            }

            /**

            * 本頁開始條數

            * @return int

            */

            private function star() {

            if ($this->total == 0) {

            return 0;

            } el {

            return ($this->page - 1) * $this->pageSize + 1;

            }

            }

            /**

            * 本頁結束條數

            * @return type

            */

            private function end() {

            return min($this->page * $this->pageSize, $this->total);

            }

            /**

            * 設置當前頁大小

            * @return type

            */

            private function tPageSize() {

            return $this->end() - $this->star() + 1;

            }

            /**

            * 首頁

            * @return type

            */

            private function frist() {

            $html = '';

            if ($this->page == 1) {

            $html .= $this->replace("{$this->uri}&page=1", $this->config['frist'], true);

            } el {

            $html .= $this->replace("{$this->uri}&page=1", $this->config['frist'], fal);

            }

            return $html;

            }

            /**

            * 上一頁

            * @return type

            */

            private function prev() {

            $html = '';

            if ($this->page > 1) {

            $html .= $this->replace($this->uri.'&page='.($this->page - 1), $this->config['pre'], fal);

            } el {

            $html .= $this->replace($this->uri.'&page='.($this->page - 1), $this->config['pre'], true);

            }

            return $html;

            }

            /**

            * 分頁數字列表

            * @return type

            */

            private function pagelist() {

            $linkpage = "";

            $lastlist = floor($this->listnum / 2);

            for ($i = $lastlist; $i >= 1; $i--) {

            $page = $this->page - $i;

            if ($page >= 1) {

            $linkpage .= $this->replace("{$this->uri}&page={$page}", $page, fal);

            } el {

            continue;

            }

            }

            $linkpage .= $this->replace("{$this->uri}&page={$this->page}", $this->page, true);

            for ($i = 1; $i <= $lastlist; $i++) {

            $page = $this->page + $i;

            if ($page <= $this->pageNum) {

            $linkpage .= $this->replace("{$this->uri}&page={$page}", $page, fal);

            } el {

            break;

            }

            }

            return $linkpage;

            }

            /**

            * 下一頁

            * @return type

            */

            private function next() {

            $html = '';

            if ($this->page < $this->pageNum) {

            $html .= $this->replace($this->uri.'&page='.($this->page + 1), $this->config['next'], fal);

            } el {

            $html .= $this->replace($this->uri.'&page='.($this->page + 1), $this->config['next'], true);

            }

            return $html;

            }

            /**

            * 最后一頁

            * @return type

            */

            private function last() {

            $html = '';

            if ($this->page == $this->pageNum) {

            $html .= $this->replace($this->uri.'&page='.($this->pageNum), $this->config['last'], true);

            } el {

            $html .= $this->replace($this->uri.'&page='.($this->pageNum), $this->config['last'], fal);

            }

            return $html;

            }

            /**

            * 跳轉按鈕

            * @return string

            */

            private function gopage() {

            $html = '';

            $html.=' <input type="text" value="' . $this->page . '" onkeydown="javascript:if(event.keyCode==13){var page=(this.value>' . $this->pageNum . ')?' . $this->pageNum . ':this.value;location='' . $this->uri . '&page='+page+''}" style="width:25px;"/><input type="button" onclick="javascript:var page=(this.previousSibling.value>' . $this->pageNum . ')?' . $this->pageNum . ':this.previousSibling.value;location='' . $this->uri . '&page='+page+''" value="GO"/>';

            return $html;

            }

            /**

            * 模板替換

            * @param type $replace 替換內容

            * @param type $result 條件

            * @return type

            */

            private function replace($url, $text, $result = true) {

            $template = ($result ? $this->activeTemplate : $this->notActiveTemplate);

            $html = str_replace('{url}', $url, $template);

            $html = str_replace('{text}', $text, $html);

            return $html;

            }

            }

            本文發布于:2023-02-28 21:00:00,感謝您對本站的認可!

            本文鏈接:http://m.newhan.cn/zhishi/a/1677715300100039.html

            版權聲明:本站內容均來自互聯網,僅供演示用,請勿用于商業和其他非法用途。如果侵犯了您的權益請與我們聯系,我們將在24小時內刪除。

            本文word下載地址:php分頁(php分頁代碼).doc

            本文 PDF 下載地址:php分頁(php分頁代碼).pdf

            標簽:分頁   代碼   php
            相關文章
            留言與評論(共有 0 條評論)
               
            驗證碼:
            推薦文章
            排行榜
            Copyright ?2019-2022 Comsenz Inc.Powered by ? 實用文體寫作網旗下知識大全大全欄目是一個全百科類寶庫! 優秀范文|法律文書|專利查詢|
            主站蜘蛛池模板: 天堂mv在线mv免费mv香蕉| 一边亲着一面膜的免费版电视剧 | 蜜桃在线免费观看网站| 国内少妇人妻丰满av| 人妻丰满熟妇AV无码区APP| 青青草国产精品日韩欧美| 亚洲精品成人福利网站| 尤物视频色版在线观看| 国产精品污一区二区三区| 人妻无码视频一区二区三区| 亚洲欧美一区二区成人片| 日韩一本不卡一区二区三区| 亚洲欧洲一区二区精品| 亚洲色欲色欲WWW在线丝| 亚洲国产色播AV在线| 国产成人久久精品激情91| 欧美国产中文| 日本三级香港三级三级人妇久 | 日韩av一区二区高清不卡| 国产午夜福利精品视频| 亚洲精品tv久久久久久久| 日本午夜免费福利视频| 欧美成年视频在线观看| 青草热在线观看精品视频| 青青青青久久精品国产| 亚洲精品成人网久久久久久| 一本久道久久综合婷婷五月| 国产精品久久国产精麻豆| 国产成人啪精品视频免费网| 亚洲精品日产AⅤ| 在线天堂最新版资源| 黑人玩弄人妻中文在线| 国产亚洲欧洲aⅴ综合一区| ........天堂网www在线| 办公室强奷漂亮少妇视频| 国产亚洲AV电影院之毛片| 在线视频不卡在线亚洲| 一区二区不卡99精品日韩| 亚洲AV永久久久久久久浪潮| 亚洲情综合五月天| 真人性囗交视频|