400-696-8028

PHP&MYSQL数据库分页显示的类

长沙北大青鸟作者:科泰校区匿名

摘要:<?/*PHP控制MYSQL分页显示的类*//* *数据库分页显示的类 */ class Page_class { var $TotalPages, $CurrentPage, $NumPerPage, $QueryStr, $Result, $DBID,$Data; var $TotalRecords, $StartRecord, $EndRecord, $Ro
<?

/*

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("没有这一行数据");



}

}



?>
 
关于我们
公司简介
发展历程
青鸟荣誉
联系我们
加入我们
青鸟课程
BCVE视频特效课程
BCUI全链路UI设计
BCSP软件开发专业
BCNT网络工程师
启能职业教育基础课程
长沙初中生学什么
长沙高中生学什么
长沙大学生学什么