php分页代码 页数太多,php google或baidu分页代码
php实现google与baidu的分页代码,需要的朋友可以参考下。
/**
作者:潇湘博客
时间:
2009-11-26
php技术群:
37304662
使用方法:
include_once'Pager.class.php';
$pager=new Pager();
if(isset($_GET['page']))
$pager->setCurrentPage($_GET['page']);
else
$pager->setCurrentPage(1);
$pager->setRecorbTotal(1000);
$pager->setBaseUri("page.php?");
echo $pager->execute();
**/
class Pager{
/**
*int总页数
**/
protected $pageTotal;
/**
*int上一页
**/
protected $previous;
/**
*int下一页
**/
protected $next;
/**
*int中间页起始序号
**/
protected $startPage;
/**
*int中间页终止序号
**/
protected $endPage;
/**
*int记录总数
**/
protected $recorbTotal;
/**
*int每页显示记录数
**/
protected $pageSize;
/**
*int当前显示页
**/
protected $currentPage;
/**
*string基url地址
**/
protected $baseUri;
/**
*@returnstring获取基url地址
*/
public function getBaseUri(){
return$this->baseUri;
}
/**
*@returnint获取当前显示页
*/
public function getCurrentPage(){
return $this->currentPage;
}
/**
*@returnint获取每页显示记录数
*/
public function getPageSize(){
return $this->pageSize;
}
/**
*@returnint获取记录总数
*/
public function getRecorbTotal(){
return$this->recorbTotal;
}
/**
*@paramstring$baseUri设置基url地址
*/
public function setBaseUri($baseUri){
$this->baseUri=$baseUri;
}
/**
*@paramint$currentPage设置当前显示页
*/
public function setCurrentPage($currentPage){
$this->currentPage=$currentPage;
}
/**
*@paramint$pageSize设置每页显示记录数
*/
public function setPageSize($pageSize){
$this->pageSize=$pageSize;
}
/**
*@paramint$recorbTotal设置获取记录总数
*/
public function setRecorbTotal($recorbTotal){
$this->recorbTotal=$recorbTotal;
}
/**
*构造函数
**/
public function __construct()
{
$this->pageTotal=0;
$this->previous=0;
$this->next=0;
$this->startPage=0;
$this->endPage=0;
$this->pageSize=20;
$this->currentPage=0;
}
/**
*分页算法
**/
private function arithmetic(){
if($this->currentPage<1)
$this->currentPage=1;
$this->pageTotal=floor($this->recorbTotal/$this->pageSize)+($this->recorbTotal%$this->pageSize>0?1:0);
if($this->currentPage>1&&$this->currentPage>$this->pageTotal)
header('location:'.$this->baseUri.'page='.$this->pageTotal);
$this->next=$this->currentPage+1;
$this->previous=$this->currentPage-1;
$this->startPage=($this->currentPage+5)>$this->pageTotal?$this->pageTotal-10:$this->currentPage-5;
$this->endPage=$this->currentPage<5?11:$this->currentPage+5;
if($this->startPage<1)
$this->startPage=1;
if($this->pageTotalendPage)
$this->endPage=$this->pageTotal;
}
/**
*分页样式
**/
protected function pageStyle(){
$result="共".$this->pageTotal."页";
if($this->currentPage>1)
$result.="baseUri."page=1\">第1页 baseUri."page=$this->previous\">前一页";
else
$result.="第1页 ";
for($i=$this->startPage;$i<=$this->endPage;$i++){
if($this->currentPage==$i)
$result.="$i";
else
$result.=" baseUri."page=$i\">$i ";
}
if($this->currentPage!=$this->pageTotal){
$result.="baseUri."page=$this->next\">后一页 ";
$result.="baseUri."page=$this->pageTotal\">最后1页";
}else{
$result.="最后1页 ";
}
return $result;
}
/**
*执行分页
**/
public function execute(){
if($this->baseUri!=""&&$this->recorbTotal==0)
return"";
$this->arithmetic();
return $this->pageStyle();
}
}
?>
php分页代码 页数太多,php google或baidu分页代码相关推荐
- php分页代码 页数太多,php分页函数示例代码分享
一例php分页函数代码. 分享一例php分页函数代码,用此函数实现分页代码很不错. 代码,php分页函数. /* * 使用方法: require_once('mypage.php'); $result ...
- 分页总页数计算方法 所有分页通用
分页总页数计算方法 总页数=(总页数+页大小-1)/页大小 2016-08-23 01:06:09 转载于:https://www.cnblogs.com/webenh/p/5797807.html
- PDF转Word提示页数太多转换失败怎么办?
将PDF转换成Word是我们日常工作中经常会用到的,但有些时候转换时却提示页数太多无法转换,强行转换也总是失败,这是怎么回事呢?要怎么才能转换呢? 一般普通的文档只有几十页多一些几百页,但是也有少部分 ...
- php 分页 页数多,一个php页面多个分页共存
PHP 分页 写了个php分页的自定义函数,用着感觉挺好: pageFunc($dataNum,$pageSize,$pageName)//记录集,每页显示的条数,分页名 今天突然在想,如果我一个页面 ...
- mysql分页总页数算法解析_详解MySQL的limit用法和分页查询语句的性能分析
limit用法 在我们使用查询语句的时候,经常要返回前几条或者中间某几行数据,这个时候怎么办呢?不用担心,mysql已经为我们提供了这样一个功能. SELECT * FROM table LIMIT ...
- git 查看修改的代码行数,新增的文件以及删除的代码行数
有时候想知道提交的代码修改了哪些文件,以及新增和删除的代码行数 git 命令: git log --stat
- python 代码行数统计工具_使用Python设计一个代码统计工具
问题 设计一个程序,用于统计一个项目中的代码行数,包括文件个数,代码行数,注释行数,空行行数.尽量设计灵活一点可以通过输入不同参数来统计不同语言的项目,例如: # type用于指定文件类型 pytho ...
- php分页显示页数代码,php-Codeigniter分页显示结果数和页数
我正在使用Codeigniter 3,并且有一个简单的PHP应用程序. 使用分页类,我想在每个页面的顶部显示以下内容: Showing x to y of z results 哪里; x = star ...
- PDF页数太多,怎么拆分成几个PDF
现在很多资料都是以PDF存在的.有的时候一篇PDF太长,读起来会非常费劲,会大量消耗我们的时间,降低办公的效率.所以,如果能将PDF拆分成几个部分就好了.那么,PDF怎么拆分成几份呢?今天就给大家分享 ...
最新文章
- select的value值为对象时,获取label和value
- git 使用及常用命令
- linux进程--exec详解(四)
- WPF DatePicker 默认显示当前时间
- math标准库函数功能汇总
- 电脑编程用户注册界面java_用JSP/Servlet开发简单的用户注册系统
- ARM assembly instruction set 汇总(一)
- Linux下汇编语言学习笔记65 ---
- .NetCore 2.1以后的HttpClient最佳实践
- python学习与数据挖掘_Python学习之数据挖掘(三)
- 论文浅尝 | CoRR - 面向复杂知识问答的框架语义解析方法
- “毕业1年,做Python挣了50W!”网友:吹得太少..
- 无限极评论怎么删除php,TP5 无限极评论回复
- oracle ebs应用产品安全性-交叉验证规则
- 【数据结构笔记30】拓扑排序、AOV网络、AOE网络、关键工序
- python数据库def函数_Python:函数
- 高阶常微分方程的求解
- python登陆126邮箱记录
- 基于双月数据集利用感知层进行分类
- 解决PHP7中微信(小程序)mcrypt_module_open() 无法使用的解决方法
热门文章
- 介绍一种找bug的方法
- 2021年6月3日,SAP 全球蓝宝石大会将在线上盛大启幕
- 一个关于Angular Directive selector里的中括号使用问题
- SAP Spartacus User Form里checkbox的设计原理
- Angular Injection Token records map的填充原理
- SAP S/4HANA Customer Management(CRM)模块的扩展性设计
- ant build.xml文件将使用到的属性放到一个额外的build.properties文件里
- 有感而发 - 日新月异的SAP开发技术
- 如何启用SAP Business by design里的Correction Invoice功能
- when is odata request sent for Live report in SAP CRM