• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php google或baidu分页代码_php技巧

php 搞代码 4年前 (2022-01-26) 7次浏览 已收录 0个评论
<?php <BR>/** <br><br>作者:潇湘博客 <br><br>时间: <BR>2009-11-26 <br><br>php技术群: <BR>37304662 <br><br>使用方法: <BR>include_once'Pager.class.php'; <BR>$pager=new Pager(); <BR>if(isset($_GET['page'])) <BR>$pager->setCurrentPage($_GET['page']); <BR>else <BR>$pager->setCurrentPage(1); <br><br>$pager->setRecorbTotal(1000); <BR>$pager->se<mark style="color:transparent">来4源gaodaimacom搞#代%码*网</mark><code>搞代gaodaima码</code>tBaseUri("page.php?"); <BR>echo $pager->execute(); <br><br>**/ <BR>class Pager{ <BR>/** <BR>*int总页数 <BR>**/ <BR>protected $pageTotal; <BR>/** <BR>*int上一页 <BR>**/ <BR>protected $previous; <BR>/** <BR>*int下一页 <BR>**/ <BR>protected $next; <BR>/** <BR>*int中间页起始序号 <BR>**/ <BR>protected $startPage; <BR>/** <BR>*int中间页终止序号 <BR>**/ <BR>protected $endPage; <BR>/** <BR>*int记录总数 <BR>**/ <BR>protected $recorbTotal; <BR>/** <BR>*int每页显示记录数 <BR>**/ <BR>protected $pageSize; <BR>/** <BR>*int当前显示页 <BR>**/ <BR>protected $currentPage; <BR>/** <BR>*string基url地址 <BR>**/ <BR>protected $baseUri; <br><br>/** <BR>*@returnstring获取基url地址 <BR>*/ <BR>public function getBaseUri(){ <BR>return$this->baseUri; <BR>} <br><br>/** <BR>*@returnint获取当前显示页 <BR>*/ <BR>public function getCurrentPage(){ <BR>return $this->currentPage; <BR>} <br><br>/** <BR>*@returnint获取每页显示记录数 <BR>*/ <BR>public function getPageSize(){ <BR>return $this->pageSize; <BR>} <br><br>/** <BR>*@returnint获取记录总数 <BR>*/ <BR>public function getRecorbTotal(){ <BR>return$this->recorbTotal; <BR>} <br><br>/** <BR>*@paramstring$baseUri设置基url地址 <BR>*/ <BR>public function setBaseUri($baseUri){ <BR>$this->baseUri=$baseUri; <BR>} <br><br>/** <BR>*@paramint$currentPage设置当前显示页 <BR>*/ <BR>public function setCurrentPage($currentPage){ <BR>$this->currentPage=$currentPage; <BR>} <br><br>/** <BR>*@paramint$pageSize设置每页显示记录数 <BR>*/ <BR>public function setPageSize($pageSize){ <BR>$this->pageSize=$pageSize; <BR>} <br><br>/** <BR>*@paramint$recorbTotal设置获取记录总数 <BR>*/ <BR>public function setRecorbTotal($recorbTotal){ <BR>$this->recorbTotal=$recorbTotal; <BR>} <br><br>/** <BR>*构造函数 <BR>**/ <BR>public function __construct() <BR>{ <BR>$this->pageTotal=0; <BR>$this->previous=0; <BR>$this->next=0; <BR>$this->startPage=0; <BR>$this->endPage=0; <br><br>$this->pageSize=20; <BR>$this->currentPage=0; <BR>} <br><br>/** <BR>*分页算法 <BR>**/ <BR>private function arithmetic(){ <BR>if($this->currentPage<1) <BR>$this->currentPage=1; <br><br>$this->pageTotal=floor($this->recorbTotal/$this->pageSize)+($this->recorbTotal%$this->pageSize>0?1:0); <br><br>if($this->currentPage>1&&$this->currentPage>$this->pageTotal) <BR>header('location:'.$this->baseUri.'page='.$this->pageTotal); <br><br>$this->next=$this->currentPage+1; <BR>$this->previous=$this->currentPage-1; <br><br>$this->startPage=($this->currentPage+5)>$this->pageTotal?$this->pageTotal-10:$this->currentPage-5; <BR>$this->endPage=$this->currentPagecurrentPage+5; <br><br>if($this->startPage<1) <BR>$this->startPage=1; <br><br>if($this->pageTotalendPage) <BR>$this->endPage=$this->pageTotal; <BR>} <br><br>/** <BR>*分页样式 <BR>**/ <br><br><BR>protected function pageStyle(){ <BR>$result="共".$this->pageTotal."页"; <br><br>if($this->currentPage>1) <BR>$result.="baseUri."page=1\"><font style="font-family:webdings">第1页</font> baseUri."page=$this->previous\">前一页</font>"; <BR>else <BR>$result.="<font style="font-family:webdings">第1页</font> <font style="font-family:webdings"></font>"; <br><br>for($i=$this->startPage;$iendPage;$i++){ <BR>if($this->currentPage==$i) <BR>$result.="<font color="#ff0000">$i</font>"; <BR>else <BR>$result.=" baseUri."page=$i\">$i "; <BR>} <br><br>if($this->currentPage!=$this->pageTotal){ <BR>$result.="baseUri."page=$this->next\"><font style="font-family:webdings">后一页</font> "; <BR>$result.="baseUri."page=$this->pageTotal\"><font style="font-family:webdings">最后1页</font>"; <BR>}else{ <BR>$result.="<font style="font-family:webdings">最后1页</font> <font style="font-family:webdings"></font>"; <BR>} <BR>return $result; <BR>} <br><br><br><br>/** <BR>*执行分页 <BR>**/ <BR>public function execute(){ <BR>if($this->baseUri!=""&&$this->recorbTotal==0) <BR>return""; <BR>$this->arithmetic(); <BR>return $this->pageStyle(); <BR>} <BR>} <BR>?><BR>

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php google或baidu分页代码_php技巧
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址