Home > Backend Development > PHP Tutorial > Powerful PHP paging code class_PHP tutorial

Powerful PHP paging code class_PHP tutorial

WBOY
Release: 2016-07-20 11:06:25
Original
815 people have browsed it

This tutorial provides you with a discuz forum style paging code. We wrote this code into a function. Let’s take a look.

This tutorial provides you with a discuz forum style paging code. We wrote this code into a function. Let’s take a look.

//Paging is the number of pages
function getPage($page,$pageSize){
$this->getRowsCount();
$this->getPageCount($pageSize) ;
//print $this->pageCount;
if(($page ==="") || ($page<"1") || (!ereg("[0-9]+ ",$page))){
$this->notePage = "1";
}else if($page>$this->pageCount){
$this->notePage = $this->pageCount;
}else{
$this->notePage = $page;
}
return $this->notePage;
}

//Get the total number of records
function getRowsCount(){
$this->getRes($this->sql_number);
$row = $this->getRows();
$this->number = $row[0];
return $this->number;
}

//Get the number of pages

function getPageCount($pageSize ){
$this->pageCount = ceil($this->number/$pageSize);
return $this->pageCount;
}

//Paging code
function getPageContent($page,$url,$pageSize){
if($page=="1"){
$view.=" [Home]";
$view.= " [Previous page]";
}else{
$view.=" [Home]";
$view.=" [Previous page]";
}
if ($page<$this->pageCount){
$view.=" [Next page] ";
$view.=" [Last page]" ;
}else{
$view.=" [Next page]";
$view.=" [Last page]";
}
return $view." Current page ".$page."Page/Total".$this->pageCount."Page".$this->number."Record"." Go to page ".$this->getUrl($url,$ page);
}

//Page to page
function getUrl($url,$page){
$go =" page
");
print("alert('".$speak."');");
print(" location.href='".$url."';");
print("");
}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445041.htmlTechArticleThis tutorial provides friends with a discuz forum style paging code. We wrote this code as A function, let’s take a look below. This tutorial provides you with a...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template