All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
用ASP+CSS实现网页随机背景_[Html教程]
ASP.NET教程:AccessDataSource的使用_[Asp.Net教程]
javascript实现小方框中浏览大图特效_JavaScript技术_编程技术
SQL Server安全之加密术和SQL注入攻击_[SQL Server教程]
通过SQLSERVER重启SQLSERVER服务和计算机_[SQL,Server教程]
SQL2000查询分析器中快捷键_mssql学习_编程技术
X-Space:日志发布后首页为何不更新-_php资料_编程技术
利用ICallbackEventHandle实现类似AJAX的无刷新页面_[Asp.Net教程]
ASP.NET中常用的文件上传下载方法_[Asp.Net教程]
[JS]用空格或,--,来兼容FireFox_JavaScript技术_编程技术
Reading number is top 10 pictures
Abdominal hit by iron--HangZhou best driver parking save passengers
这才是真正的人体艺术4
Soong ching ling's former residence2
陪睡门马睿菈自曝写真 称首拍大尺度照片3
这是男生笨么?
Extremely rare TianShan Mountains snow lotus2
Fierce! China's special forces training the devil2
Summer is most suitable for young people to travel in China3
Sora aoi calligraphy show
Ashlynn Brooke photograph of a group3
Download software ranking
The Bermuda triangle2
C++编程教程第三版
Unix video tutorial8
XML+Web+Service开发教程
Kung.Fu.Panda.2
The Bermuda triangle3
linux初级教程
Tram sex maniac 2 (H) rar bag2
Dance with duck(male prostitution)
美女写真1
aaa published in(发表于) 2013/12/21 22:25:39 Edit(编辑)
PHP实例源代码:PHP实现翻页处理的类_php资料_编程技术

PHP实例源代码:PHP实现翻页处理的类_php资料_编程技术

PHP实例源代码:PHP实现翻页处理的类_php资料_编程技术-你的首页-uuhomepage.com
PHP实例源代码:PHP实现翻页处理的类
class Page{
var $CountAll; //共有纪录数
var $CountPage; //每页显示记录数
var $Link; //显示 完整的分页信息
var $ForPage; //上一页
var $NextPage; //下一页
var $FirstPage; //第一页
var $LastPage; //最后一页
var $CurrPage; //第几页
var $PageNum; //共有多少页
var $Parameter; //参数
var $LimitNum; //不是统计全部记录,而是显示部分记录,例如共有100条记录,但是只统计显示前50条
function Page($sql, $num=30){
//初始化,统计记录数
$this->CountPage = $num;
global $mysql;
$sql = base64_decode($sql);
$result = $mysql->Query($sql);
if (0 != $mysql->AffectedRows()){
$row = $mysql->FetchArray($result);
$this->CountAll = $row[0];
}
else{
$this->CountAll = 0;
}
//print "共有 $this->CountAll
";
}
function ListPage($sql, $page=0,$sql_all,$other){
//查询,定义变量,获取数据
global $mysql;
//print "sql sql
";
if (isset($this->LimitNum) && $this->CountAll > $this->LimitNum){
$this->CountAll = $this->LimitNum;
}//更新总浏览记录数
$sql_src = $sql;
//if ($page > 0){
$sql = base64_decode($sql);
$sql_all = base64_decode($sql_all);
$sql_src = $sql;
//}
//echo $sql;
if (($this->CountAll % $this->CountPage) == 0)//统计共有多少页
$pagecount = (integer)($this->CountAll/$this->CountPage);
else
$pagecount = (integer)($this->CountAll/$this->CountPage)+1;
$this->ageNum = $pagecount;
if ($page > $this->ageNum)//如果页码超过页码总数则设为最大页码
$page = $this->ageNum;
if ($page <= 0)//如果页码小于等于零则将页码设置为1
$page = 1;
if ($this->CountAll == 0)
{
$this->CurrPage = 0;
}else{
$this->CurrPage = $page;
}
$first_start = ($page-1)*$this->CountPage;
$sql = $sql." limit ".$first_start.", ".$this->CountPage;
//print "2sql
";
$result = $mysql->Query($sql);
if (0 != $mysql->AffectedRows()){
$i = 0;
while($row = $mysql->FetchArray($result)){
$array[$i] = $row;
//print "name:".$array[$i][Name]."
";
$i++;
}
}
$sql = base64_encode($sql_src);
$sql_all = base64_encode($sql_all);
if ($pagecount >1){
if($page == 1){
$nextpage = $page+1;
$forpage = 1;
$this->Link = "Parameter."&sql_all=".$sql_all."".$other."'" class="button_a"
style="width:30;height:22";>
Parameter."&sql_all=".$sql_all."".$other."'" class="button_a"
style="width:30;height:22";>";
$this->NextPage = "Parameter."&sql_all=".$sql_all."".$other."'"
class="button_a" style="width:30;height:22";>";
$this->LastPage = "Parameter."&sql_all=".$sql_all."".$other."'"
class="button_a" style="width:30;height:22";>";
}
else if(($page > 1)&&($page < $pagecount)) {
$forpage = $page-1;
$nextpage = $page+1;
$this->Link = "Parameter."&sql_all=".$sql_all."".$other."'" class="button_a"
style="width:30;height:22";>
Parameter."&sql_all=".$sql_all."".$other."'" class="button_a"
style="width:30;height:22";>
Parameter."&sql_all=".$sql_all."".$other."'"
class="button_a" style="width:30;height:22";>
Parameter."&sql_all=".$sql_all."".$other."'" class="button_a"
style="width:30;height:22";>";
$this->ForPage = "Parameter."&sql_all=".$sql_all."".$other."'"
class="button_a" style="width:30;height:22";>";
$this->NextPage = "Parameter."&sql_all=".$sql_all."".$other."'"
class="button_a" style="width:30;height:22";>";
$this->FirstPage = "Parameter."&sql_all=".$sql_all."".$other."'"
class="button_a" style="width:30;height:22";>";
$this->LastPage = "Parameter."&sql_all=".$sql_all."".$other."'"
class="button_a" style="width:30;height:22";>";
}
else if ($page = $pagecount){
$forpage = $page-1;
$nextpage = 1;
$this->Link = "Parameter."&sql_all=".$sql_all."".$other."'"
class="button_a" style="width:30;height:22";>
Parameter."&sql_all=".$sql_all."".$other."'" class="button_a"
style="width:30;height:22";>";
$this->FirstPage = "Parameter."&sql_all=".$sql_all."".$other."'"
class="button_a" style="width:30;height:22";>";
$this->ForPage = "Parameter."&sql_all=".$sql_all."".$other."'"
class="button_a" style="width:30;height:22";>";
}
}
else{
$this->Link = ' ';
}
return $array;//$array;
}
}
/***************
使用例子
include("class.config.php");
include("class.mysql.php");
include("class.page.php");
global $mysql;
$config = new Config;
$mysql = new TDatabase($config);
$query_all = "select count(*) from user";
$page_object = new Page($query_all,20);
//new Page('统计记录个数语句',每页记录个数)
if(empty($query_page))
$query_sql = "select * from user";
//注意这里的变量名必须为 $query_sql $query_page ,因为下一页的连接参数默认为 query_sql query_page
$list = $page_object->ListPage($query_sql,$query_page);
//ListPage('没有limit的前一部分,系统自动根据补齐',察看的页数)
$page_object->Parameter = '&action=view';
//这是传送的Url 所带的其它参数,如果有就修改变量 Parameter ,系统自动将她补在后面
//显示数据
for ($i=0;$i< $page_object->CountPage;$i++)
print $list[$i][ID]."->".$list[$i][UserName]."
";
//返回的数据为二维哈西(关联)数组,一维为纪录的标识ID号,二维为哈西(关联)数组,取值标识建议采取用数据库中字段名的方法,例如list[0][UserName]。
//显示其他相关数据
echo $page_object->CountAll;//纪录总数
echo $page_object->CountPage;//每页显示数据个数
echo $page_object->Link;//显示完整的分页信息
echo $page_object->FirstPage;//第一页
echo $page_object->NextPage;//下一页
echo $page_object->ForPage;//上一页
echo $page_object->LastPage;//最后一页
echo $page_object->CurrPage;//第几页
echo $page_object->PageNum;//共有多少页
$mysql->DatabaseClose();
****************/
?>



添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.