帝国软件
  设为首页 加入收藏 关于我们
 
解密帝国网站管理系统
栏 目:
 
您的位置:首页 > 技术文档 > PHP编程
PHP&MYSQL数据库分页显示的类
作者:匿名 发布时间:2002-12-21 来源:WWW.EATSUN.COM
<?

/*

PHP控制MYSQL分页显示的类

*/

/*

*数据库分页显示的类

*/



class Page_class {



var $TotalPages, $CurrentPage, $NumPerPage, $QueryStr, $Result, $DBID,$Data;

var $TotalRecords, $StartRecord, $EndRecord, $RowCount ;



function Setup ($NumPerPage) {

$this->NumPerPage = $NumPerPage;

}



function InitPage ($QueryStr,$ID) {

$this->QueryStr = $QueryStr;

$this->DBID = $ID;

$Query = "select COUNT(*) ".strstr($QueryStr,"from");

$this->Result = @mysql_query($Query,$this->DBID) or die("内部错误,请联系管理员");

$this->Data = @mysql_fetch_array($this->Result);

$this->TotalRecords = $this->Data[0];

if ($this->NumPerPage > $this->TotalRecords) {

$this->TotalPages = 1 ;

}

else $this->TotalPages = Ceil($this->TotalRecords/$this->NumPerPage) ;

}



function GetPage ($CurrentPage) {

if ($CurrentPage > $this->TotalPages || $CurrentPage < 1) {

return("错误,没有此页");

}

else {

$this->CurrentPage = $CurrentPage ;

$this->StartRecord = ($this->CurrentPage - 1)*$this->NumPerPage;

$this->EndRecord = $this->CurrentPage * $this->NumPerPage;

$Query = $this->QueryStr." LIMIT ".$this->StartRecord.",".$this->NumPerPage;

$this->Result = @mysql_query($Query,$this->DBID) or die("查询语句出错,请检查语法");

$this->RowCount = @mysql_num_rows($this->Result);

$this->StartRecord += 1;

return($Query);

}

}



function GetData ($Row) {

@mysql_data_seek($this->Result,$Row) or die("没有这一行数据");

$this->Data = @mysql_fetch_array($this->Result) or die("没有这一行数据");



}

}



?>
 
  
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
无相关信息

   栏目导行
  PHP编程
  ASP编程
  ASP.NET编程
  JAVA编程
   站点最新
·致合作伙伴的欢迎信
·媒体报道
·帝国软件合作伙伴计划协议
·DiscuzX2.5会员整合通行证发布
·帝国CMS 7.0版本功能建议收集
·帝国网站管理系统2012年授权购买说
·PHPWind8.7会员整合通行证发布
·[官方插件]帝国CMS-访问统计插件
·[官方插件]帝国CMS-sitemap插件
·[官方插件]帝国CMS内容页评论AJAX分
   类别最新
·Windows下集成安装Apache,PHP,MYSQ
·Mysql注入:SQL Injection with MyS
·PHP 的来龙去脉
·PHP 的功能概述
·PHP与其它CGI的比较
·PHP 的编译配置详细选项
·php.ini 配置详细选项
·如何写作PHP程序
·Hello,World
·嵌入方法
 
关于帝国 | 广告服务 | 联系我们 | 程序开发 | 网站地图 | 留言板 帝国网站管理系统