免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1176 | 回复: 0
打印 上一主题 下一主题

自己写的个php分页类 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-21 09:54 |只看该作者 |倒序浏览

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_sizepage_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_pagetotal_page&&$current_page>0)
   {
    if($current_page==1)
    {
     $current_page+=1;
     $this->current_url=""."下一页";
    }
    else if($current_page==$this->total_page)
    {
     $current_page-=1;
     $this->current_url=""."上一页";
    }
    else
    {
     $prev_page=$current_page-1;
     $next_page=$current_page+1;
     $this->current_url=""."上一页"."  ".""."下一页";
    }   
   }
   else
   {
    $this->current_url=$this->get_current_url($start_url,$this->total_page);
   }
  }
  return $this->current_url;
}
}
?>
我根据网络上分页说明,自己做了个分页类,没有设计数据库操作。只是纯粹根据数据记录分页。


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/14585/showart_158211.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP