亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

搜索
首頁 > php教程 > php手冊 > 正文

今天寫的分頁類......分享

php中文網(wǎng)
發(fā)布: 2016-06-21 09:11:20
原創(chuàng)
1150人瀏覽過

分頁

由于是上班時候?qū)懙?,所以如果全部由部貼出來恐怕對不起公司,所以我把其中的表單跳轉(zhuǎn)刪去了。別見怪哦。。。

格式寫法是比較標準的了

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
[][>>]

*****/



最佳 Windows 性能的頂級免費優(yōu)化軟件
最佳 Windows 性能的頂級免費優(yōu)化軟件

每個人都需要一臺速度更快、更穩(wěn)定的 PC。隨著時間的推移,垃圾文件、舊注冊表數(shù)據(jù)和不必要的后臺進程會占用資源并降低性能。幸運的是,許多工具可以讓 Windows 保持平穩(wěn)運行。

下載
來源:php中文網(wǎng)
本文內(nèi)容由網(wǎng)友自發(fā)貢獻,版權歸原作者所有,本站不承擔相應法律責任。如您發(fā)現(xiàn)有涉嫌抄襲侵權的內(nèi)容,請聯(lián)系admin@php.cn
最新問題
開源免費商場系統(tǒng)廣告
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板
關于我們 免責申明 意見反饋 講師合作 廣告合作 最新更新
php中文網(wǎng):公益在線php培訓,幫助PHP學習者快速成長!
關注服務號 技術交流群
PHP中文網(wǎng)訂閱號
每天精選資源文章推送
PHP中文網(wǎng)APP
隨時隨地碎片化學習
PHP中文網(wǎng)抖音號
發(fā)現(xiàn)有趣的

Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號