- 浏览: 400886 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
wcjagta:
...
dedecms插件开发教程 -
xc2013:
看起来不错 先下载来试试
ECSHOP完全静态化解决方法 -
greemranqq:
你好,我在xp 上做实验,也是JS css带不过来,关于 ro ...
nginx资源定向 css js路径问题 -
hotsmile:
表结构给出来吧,测试的提示说要注册,
中国移动CMPP短信开发平台通讯包 2.8 -
mengdejun:
gang80306176 写道这个插件怎么用和安装普通插件一样 ...
phpcms2008 sp4单网页编辑器插件
<?php interface ILink { public function parse($page,$param); } ?>
<?php require'ILink.php'; class LinkAdapter implements ILink { /** * @param unknown_type $page * @param unknown_type $param */ public function parse($page, $param) { $temp="共{$page->getAllPage()}页,第{$page->getCurrentPage()}页 "; $links=$this->getLinkString($param); if($page->hasPrevious())$temp.="<a href='$links=".($page->getCurrentPage()-1)."'>上一页</a> ";else{$temp.="上一页 ";} for($i=$page->getCurrentPage();$i<=$page->getAllPage()&&$i<=$page->getPerRecords();$i++) { $temp.="<a href='$links=$i'>{$i}</a> "; } if($page->hasNext())$temp.="<a href='$links=".($page->getCurrentPage()+1)."'>下一页</a> ";else{$temp.="下一页 ";} return $temp; } public function getLinkString($param) { $str=""; $attr=$_GET; unset($attr[$param]); if($attr) { foreach($attr as $key=>$val) { if($str=="") { $str.="?$key=$val"; } else { $str.="&$key=$val"; } } $str.="&$param"; } else { $str.="?$param"; } return $str; } } ?>
<?php class Page { private $allPage;#总页数 private $allRecords;#总记录数 private $perRecords;#单页记录数 private $currentPage=1;#当前页面 /** * @return the $allPage */ public function getAllPage() { return $this->allPage; } /** * @return the $allRecords */ public function getAllRecords() { return $this->allRecords; } /** * @return the $perRecords */ public function getPerRecords() { return $this->perRecords; } /** * @return the $currentPage */ public function getCurrentPage() { return $this->currentPage; } /** * @param $allPage the $allPage to set */ public function setAllPage($allPage) { $this->allPage = ($allPage%$this->perRecords == 0)?($allPage/$this->perRecords):($allPage/$this->perRecords+1); $this->allPage=intval($this->allPage); } /** * @param $allRecords the $allRecords to set */ public function setAllRecords($allRecords) { $this->allRecords = $allRecords; } /** * @param $perRecords the $perRecords to set */ public function setPerRecords($perRecords) { $this->perRecords = $perRecords; } /** * @param $currentPage the $currentPage to set */ public function setCurrentPage($currentPage) { if ($currentPage < 1) $this->currentPage = 1; else if ($currentPage > $this->allPage) $this->currentPage =$this->allPage; else $this->currentPage=$currentPage; } public function hasNext() { return $this->currentPage<$this->allPage; } public function hasPrevious() { return $this->currentPage>1; } public function getEndIndex() { return ((($this->currentPage-1)*$this->perRecords)+$this->perRecords)>$this->allRecords?((($this->currentPage-1)*$this->perRecords)+$this->perRecords)-$this->allRecords:$this->perRecords; } public function getStartIndex() { return ($this->currentPage-1)*$this->perRecords; } } ?>
<?php require'Page.php'; require'LinkAdapter.php'; class Pager { private $list=array(); private $page;#分页对象 private $param;#页面请求参数 public function __construct($list) { $this->list=$list; $this->page=new Page(); } /** * * @param unknown_type $rows 显示的数据量 * @param unknown_type $current 当前页 */ public function init($rows=5,$current) { $this->page->setAllRecords(count($this->list)); $this->page->setPerRecords($rows); $this->page->setAllPage(count($this->list)); $this->page->setCurrentPage($current); $this->list=array_slice($this->list,$this->page->getStartIndex(),$this->page->getEndIndex()); } /** * 获取分页变量 */ public function getVar() { return $this->list; } /** * @return the $param */ public function getParam() { return $this->param; } /** * @param $param the $param to set */ public function setParam($param) { $this->param = $param; } /** * 加载插件信息,获取生成的链接,装饰器模式 * @param unknown_type $link */ public function getLink($link=null) { if(!empty($link)||!(($link instanceof ILink)))$link=new LinkAdapter(); return $link->parse($this->page,$this->param); } } ?>
<?php include'lib/Pager.php'; $target=array(); for($i=0;$i<=100;$i++){$target[]=$i;} $page=new Pager($target); $page->setParam("page"); $page->init(30,$_REQUEST['page']); $list=$page->getVar(); foreach($list as $val): echo $val.'<br/>'; endforeach; echo $page->getLink(); ?>
- pager_php_tag.rar (1.9 KB)
- 下载次数: 17
发表评论
-
php异步操作类库
2011-06-05 16:01 1778httpclient for php 的选择常用方案有以 ... -
织梦HTTP IMAGE下载类
2011-06-05 14:57 1853<?php if(!defined('DEDEINC ... -
php汉字转拼音
2011-06-05 14:41 1572<?php /**************** ... -
PHP采集利器:Snoopy 试用心得
2011-06-05 14:34 14021Snoopy是一个php类,用 ... -
php异步调用 提高用户体验
2011-05-30 14:22 1291这是我的一个技术很好的朋友写的,要我发表在我的博客上可让php ... -
PHP 异步调用 后台调用 持续执行 断开连接/浏览器
2011-05-26 10:31 1679标题很怪,因为我也 ... -
php socket模拟POST GET请求 fsockopen版
2011-05-26 10:14 7340function httpRequestGET($url){ ... -
php socket GET POST提交方法(HttpClient) 框架
2011-05-25 18:29 5514<?php /* Version 0.9, 6th ... -
mantis
2011-05-25 09:50 1250mantis 缺陷管理平台Mantis,也做Mantis ... -
Curl参数一览
2011-05-06 17:30 1447* 目录 1. 介绍 ... -
PHPRPC
2011-04-24 11:01 1289PHPRPC 是一个轻型的、安全的、跨网际的、跨语言的、跨平台 ... -
PHP身份证验证程序
2011-04-24 10:56 1241<?php // 计算身份证校验码,根据国家标准GB 116 ... -
nginx 502 Bad Gateway 错误问题收集
2011-04-23 09:43 1733502是FastCGI出现问题,所以从FastCGI配置入手。 ... -
深入理解PHP内存管理之谁动了我的内存
2011-04-12 21:57 828首先让我们看一个问题: ... -
socket模拟post表单
2011-04-11 15:40 2772post的本质就是发送给目的程序一个标志为post的协议串如下 ... -
OAUTH协议
2011-04-09 09:59 1064OAUTH协议为用户资源的 ... -
nginx/windows: 让nginx以服务的方式运行
2011-04-09 09:33 1126在windows下安装了nginx, 郁闷是发现它没有以服 ... -
ThinkPHP处理海量数据分表机制详细代码
2011-04-07 18:27 7177应用ThinkPHP内置的分表算法处理百万级用户数据. ... -
php 分库分表hash算法
2011-04-07 18:16 1670//分库分表算法 function calc_hash_d ... -
nginx配置文件实例: php (fastcgi), perl, proxy, rrd, nagios
2011-04-06 20:33 1805nginx.conf worker_processes 5; ...
相关推荐
PHP通用分页类详解,在网上找的通用分页类 初学者可以看看还是蛮有用的
PHP通用分页类 v1.0-源码.zip
一个很好的分页类一个很好的分页类一个很好的分页类一个很好的分页类一个很好的分页类一个很好的分页类
写了个php的通用分页类使用方法很简单在实例化对象时只需要给他传个"每页显示记录数"和"总记录数"就可以了例:include_once("pages_class.php");连接db省略.....得到总记录数在此省略........
PHP通用分页类。本代码是用于分页用的,稍做修改可用于各种程序。使用方式请参考本人文章。
超强php分页打包 通用分页 万能分页 ajax分页 google分页
php分页类(通用)
主要介绍了PHP分页显示的方法,结合实例形式分析了php数据库查询及内容结合HTML分页显示的简单操作技巧,并附带一个PHP通用分页类供大家参考使用,需要的朋友可以参考下
写了个php的通用分页类 使用方法很简单 在实例化对象时只需要给他传个每页显示记录数和总记录数就可以了 例: include_once(pages_class.php); 连接db省略..... 得到总记录数在此省略........
PHP通用分页类(仿Google样式)。本代码是用于分页用的,只需提供记录总数与每页显示数两个参数,无需指定URL,链接由程序生成。方便用于检索结果分页,表单采用GET方法提交,可保证在诸如查询之,删除之类的操作时,...
我在一些PHP论坛上经常看到不少PHP初学者对于PHP分页很头痛,所以我就抽一点时间将我所写的网站中的 分页功能给分离出来给广大PHP初学者做为参考或者使用。 程序的优点:可用于伪静态、静态和动态分页用,...
小贤PHP通用分页程序小贤PHP通用分页程序小贤PHP通用分页程序
分享一个php实现数据分页的通用方法类,计算得出总页数,判断当前页码,去掉url中原先的page参数以便加入新的page参数。
BluePage是一个通用的分页类,它能帮助你更快地完成分页任务。 先看使用例子: http://www.bluessoft.com/project/bluepage/example.php 使用例子1: 以下为引用的内容: <?php include ( "lib/BluePage.class....
PHP通用的数据库分页类 欢迎下载学习 欢迎下载学习
NULL 博文链接:https://fly-sky.iteye.com/blog/566623
通用的分页类 自己设定查询的条件 更加灵活