文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>自己写的个php分页类

自己写的个php分页类

时间:2006-08-21  来源:pizigou


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;
}
}
?>
我根据网络上分页说明,自己做了个分页类,没有设计数据库操作。只是纯粹根据数据记录分页。


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载