您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

今天写的分页类......分享

2025/5/25 21:39:34发布12次查看
分页
由于是上班时候写的,所以如果全部由部贴出来恐怕对不起公司,所以我把其中的表单跳转删去了。别见怪哦。。。
格式写法是比较标准的了
php代码:--------------------------------------------------------------------------------
/**********
| +---------------------------------------------------
| class name: pagebar
| +---------------------------------------------------
| author: arvan [e-mail:arvan@5n9.com qq:8817776]
| create date: 2003-7-17
| note:
| do for pagination
| +---------------------------------------------------
| warning: no...
| +---------------------------------------------------
**********/
class pagebar
{
var $total;
var $onepage;
var $num;
var $pagecount;
var $total_page;
var $offset;
var $linkhead;
function pagebar($total, $onepage, $form_vars='')
{
$pagecount = $_get['pagecount'];
$this->total = $total;
$this->onepage = $onepage;
$this->total_page = ceil($total/$onepage);
if (empty($pagecount))
{
$this->pagecount = 1;
$this->offset = 0;
}
else
{
$this->pagecount = $pagecount;
$this->offset = ($pagecount-1)*$onepage;
}
if (!empty($form_vars))
{
$vars = explode(|, $form_vars);
$chk = $vars[0];
$chk_value = $_post['$chk'];
if (empty($chk_value))
{
$formlink = ;
}
else
{
for ($i=0; $i {
$var = $vars[$i];
$value = $_post['$var'];
$addchar = $vars.=.$value;
$addstr = $addstr.$addchar.&;
}
$formlink = &.substr($addstr, 0, sizeof($addstr)-1);
}
}
else
{
$formlink = ;
}
$linkarr = explode(pagecount=, $_server['query_string']);
$linkft = $linkarr[0];
if (empty($linkft))
{
$this->linkhead = $_server['php_self'].?.$formlink;
}
else
{
$this->linkhead = $_server['php_self'].?.$linkft.$formlink;
}
}
#end function pagebar();
function offset()
{
return $this->offset;
}
#end function offset();
function pre_page($char='')
{
$linkhead = $this->linkhead;
$pagecount = $this->pagecount;
if (empty($char))
{
$char = [ }
if ($pagecount>1)
{
$pre_page = $pagecount - 1;
return $char;
}
else
{
return ' ';
}
}
#end function pre_page();
function next_page($char='')
{
$linkhead = $this->linkhead;
$total_page = $this->total_page;
$pagecount = $this->pagecount;
if (empty($char))
{
$char = [>];
}
if ($pagecount {
$next_page = $pagecount + 1;
return $char;
}
else
{
return ' ';
}
}
#end function next_page();
function num_bar($num='', $color='', $left='', $right='')
{
$num = (empty($num))?10:$num;
$this->num = $num;
$mid = floor($num/2);
$last = $num - 1;
$pagecount = $this->pagecount;
$totalpage = $this->total_page;
$linkhead = $this->linkhead;
$left = (empty($left))?[:$left;
$right = (empty($right))?]:$right;
$color = (empty($color))?#ff0000:$color;
$minpage = (($pagecount-$mid)$pagecount-$mid);
$maxpage = $minpage + $last;
if ($maxpage>$totalpage)
{
$maxpage = $totalpage;
$minpage = $maxpage - $last;
$minpage = ($minpage }
for ($i=$minpage; $i {
$char = $left.$i.$right;
if ($i==$pagecount)
{
$char = $char;
}
$linkchar = .$char.;
$linkbar = $linkbar.$linkchar;
}
return $linkbar;
}
#end function num_bar();
function pre_group($char='')
{
$pagecount = $this->pagecount;
$linkhead = $this->linkhead;
$num = $this->num;
$mid = floor($num/2);
$minpage = (($pagecount-$mid)$pagecount-$mid);
$char = (empty($char))?[ $pgpagecount = ($minpage>$num)?$minpage-$mid:1;
return .$char.;
}
#end function pre_group();
function next_group($char='')
{
$pagecount = $this->pagecount;
$linkhead = $this->linkhead;
$totalpage = $this->total_page;
$num = $this->num;
$mid = floor($num/2);
$last = $num;
$minpage = (($pagecount-$mid)$pagecount-$mid);
$maxpage = $minpage + $last;
if ($maxpage>$totalpage)
{
$maxpage = $totalpage;
$minpage = $maxpage - $last;
$minpage = ($minpage }
$char = (empty($char))?[>>]:$char;
$ngpagecount = ($totalpage>$maxpage+$last)?$maxpage + $mid:$totalpage;
return .$char.;
}
#end function next_group();
function whole_num_bar($num='', $color='')
{
$num_bar = $this->num_bar($num, $color);
$pre_group = $this->pre_group();
$pre_page = $this->pre_page();
$next_page = $this->next_page();
$next_group = $this->next_group();
return $pre_group.$pre_page.$num_bar.$next_page.$next_group;
}
#end function whole_bar();
}
#end class pagebar;
/*****
//example
$total = 1000;
$onepage = 20;
$pb = new pagebar($total, $onepage);
$offset = $pb->offset();
$pagebar = $pb->whole_num_bar();
echo $offset.
.$pagebar;
return:
0
[][>>]
*****/
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product