-
-
include "pager.class.php";
- $CurrentPage=isset($_GET['page'])?$_GET[ 'page']:1;
- //死亡($CurrentPage);
- $myPage=新尋呼機(1300,intval($CurrentPage));
- $pageStr= $myPage->GetPagerContent();
- //echo $pageStr;
- $myPage=新尋呼機(90,intval($CurrentPage));
- $pageStr= $myPage->GetPagerContent();
- 回顯$pageStr;
- ?>
複製程式碼
-
-
-
-
-
-
-
-
-
-
-
>
-
php分頁示範-bbs.it-home.org
-
>
- 頭>
-
-
include "pager.class.php";
- $CurrentPage=isset($_GET['page'])?$_GET['page']:1;
- //死亡($CurrentPage);
- $myPage=新尋呼機(1300,intval($ CurrentPage));
$pageStr= $myPage->GetPagerContent(); //echo $pageStr; $myPage=新尋呼機(90,intval($CurrentPage)); $pageStr = $myPage->GetPagerContent(); 回顯$pageStr; ? > 身體> 複製程式碼2) pager.class.php:
-
-
建立於2013-03-27 * @Modify 2013-03-27
- * 範例:
- $myPage =新尋呼機(1300,intval($CurrentPage));
- $pageStr= $myPage->GetPagerContent();
- 回顯$pageStr;
- */
- class Pager {
- private pageSize = 10;
- 私有$pageIndex;
- 私人$totalNum;
私人$totalPagesCount;
私人$pageUrl;
- private static $_instance;
public function __construct($p_totalNum, $p_pageIndex, $p_pageSize = 10, $p_initNum=3, $p_initMaxNum=5) {
- if (! ) || !isset($p_pageIndex)) {
- die("頁面初始化錯誤");
- }
$this->totalNum = $p_totalNum;
- $ this->pageIndex = $p_pageIndex;
- $this->pageSize = $p_pageSize;
- $this->initNum=$p_initNum;
- $this->initMaxNum=$p_inMaxNum; >totalPagesCount= ceil($p_totalNum / $p_pageSize);
- $this->pageUrl=$this->_getPageUrl();
$this->_initPagerLegal();
- }
- /**
- * 取得移除page部分的目前網址
- *
- * @return String URL字串
- */
- 私有函數_getPageUrl() {
- $CurrentUrl = $_SERVER["REQUEST_URI"];
- $ arrUrl = parse_url($CurrentUrl);
- $urlQuery = $arrUrl["query"]
- $urlQuery = ereg_replace("(^|&)page=" $this🎜>$urlQuery = ereg_replace("(^|&)page=" $this🎜>$urlQuery = ereg_replace("(^|&)page=" $this🎜>$urlQuery = ereg_replace("(^|&)page=" $this🎜>$urlQuery = ereg_replace("(^|&)page=" $this - > pageIndex, "", $urlQuery);
- $CurrentUrl = str_replace($arrUrl["query"], $urlQuery, $CurrentUrl)";
- }
- else $CurrentUrl.="page" ;
} else {
- $CurrentUrl.="?page";
- }
return $CurrentUrl;
} *@return void
- */
- 私人函數_initPagerLegal()
- {
- if((!is_numeric($this->pageIndex)) || $this->pageIndex {
- $this->pageIndex=1;
- }elseif($this->pageIndex > $this->totalPagesCount)
- {
- $this->pageIndex=$ this->totalPagesCount;
- }
}
- //$this->pageUrl}={$i}
- / /{$this->CurrentUrl}={$this->pageUrl} TotalPages}
- public function GetPagerContent() {
- $str = "";
- 回傳$str
- }
/ * *
- * 取得實例
- * @return
- */
- // static public function getInstance() {
- // if (is_null ( self::$_instance )) {
- // self::$_instance = new pager ( ) ;
- // }
- // 回傳self::$_instance;
- // }
- }
- ?>
複製程式碼
3),php分頁樣式檔pager.css:
-
-
body,html{ padding:0px;邊距:0px;顏色:#333333;font-family:"宋體", Arial,Lucida,Verdana,Helvetica,sans-serif;字體大小:12px;行高:150%;}
- h1,h2,h3,h4,h5,h6,ul,li,dl,dt,dd,form ,img,p,label{邊距:0;填滿:0;邊框:無;list-style-type:none;}
/**前台分頁樣式**/
- .分頁{margin:10px 0 0;padding:5px 0;text-align:對對對;高度:20px;行高:20px;font-family:Arial, Helvetica, sans-serif,"宋體";}
- .分頁a {margin-left:2px;padding:2px 7px 2px;}
- .分頁.dot{ border:medium none; padding:4px 8px}
- .Pagination a:link, .Pagination a:visited {border:1pxsolid #dedede;color:#696969;text-decoration:none;}
- .Pagination a:hover, .Pagination a:active, .Pagination a.current:link, .Pagination a.current:visited { border:1pxsolid #dedede;color:#fff;背景顏色:#ff6600;背景圖像:無;邊框:#ff6600 實心1px;}
- .Pagination .selectBar{ 邊框:#dededede 實心1px;字體大小:12px;寬度:95px;高度:21px;行高:21px;左邊距:10px; display:inline}
- .Pagination a.tips{_padding:4px 7px 1px;}
-
複製程式碼
|