Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 网站建设 > PHP > 自己写的个php分页类
【标  题】:自己写的个php分页类
【关键字】:php
【来  源】:http://www.cublog.cn/u/14585/showart.php?id=158211

自己写的个php分页类

Your Ad Here
<?php
/******************
 *php分页类,适合设计到分页的程序
 *作者:痞子狗
 *2006-8-20
 ******************/
class class_div_page
{
 private $total_page_size;//总记录数
 private $page_size;//每页记录数
 private $total_page;//总页数
 private $current_url;//当前url
 public function init_data($total_page_size,$page_size)
 {
  $this->total_page_size=($total_page_size>=0)?intval($total_page_size):1;
  $this->page_size=($page_size>0)?intval($page_size):intval($total_page_size);
 }
 
 public function get_total_page()
 {
  if($this->total_page_size<=$this->page_size)
  {
   $this->total_page=1;
  }
  else
  {
   if($this->total_page_size%$this->page_size)
   {
    $this->total_page=(int)($this->total_page_size/$this->page_size)+1;
   }
   else
   {
    $this->total_page=$this->total_page_size/$this->page_size;
   }
  }
  return $this->total_page;//根据用户需要可返回总页数
 }
 
 public function get_current_url($start_url,$current_page=1)//$start_url="xxxx.php?xxx="这类形式,$current_page即为需要传递的显示页号
 {
  $current_page=(intval($current_page)>=1)?intval($current_page):1;
  $this->get_total_page();
  if($this->total_page==1)
  {
   $this->current_url="";
  }
  else
  {
   if($current_page<=$this->total_page&&$current_page>0)
   {
    if($current_page==1)
    {
     $current_page+=1;
     $this->current_url="<a href=\"".$start_url.$current_page."\">"."下一页</a>";
    }
    else if($current_page==$this->total_page)
    {
     $current_page-=1;
     $this->current_url="<a href=\"".$start_url.$current_page."\">"."上一页</a>";
    }
    else
    {
     $prev_page=$current_page-1;
     $next_page=$current_page+1; 
     $this->current_url="<a href=\"".$start_url.$prev_page."\">"."上一页</a>"."  "."<a href=\"".$start_url.$next_page."\">"."下一页</a>";
    }   
   }
   else
   {
    $this->current_url=$this->get_current_url($start_url,$this->total_page);
   }
  }
  return $this->current_url;
 }

?>
我根据网络上分页说明,自己做了个分页类,没有设计数据库操作。只是纯粹根据数据记录分页。
PHP不显示调试信息:【上一篇】
PHP 4.4.4 and PHP 5.1.5 Released:【下一篇】
【相关文章】
  • PHP不显示调试信息
  • PHP中页面与代码分离的实现
  • Linux上优化安装Apache(PHP)及基本安全设置
  • Aapche+Resin+PHP+Mysql+Proftpd虚拟主机配置过程
  • 了解实际开发中 Hashtable 的特性原理 .NET, JAVA, PHP (之一)
  • 了解实际开发中 Hashtable 的特性原理 .NET, JAVA, PHP (之二)
  • PHP 5.1.5发布
  • apache+ssl+php+mysql实现的php商务平台
  • 安装 MySQL,php 与 apache
  • (转)php一些注意地方.
  • 【随机文章】
  • symfony - pear方式安装过程
  • Kernal locking中文版(下载)
  • 在PowerPoint中插入视频的三种方法
  • 是 Bug? 還是另有作用?!
  • 递归算法计算n各元素的排列
  • 局域网内mfc/udp聊天程序
  • LINUX & Oracle: How to config locale setting corre
  • vs6中控件的设计期授权问题
  • 在Eclipse3.0中配置SQLExplorer访问数据库
  • 声音编码gsm和msgsm的转换
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.