Powerful php paging Code Class

Source: Internet
Author: User

This tutorial provides you with a paging code of the discuz forum type. We have written this code as a function. Let's take a look at it.

This tutorial provides you with a paging code of the discuz forum type. We have written this code as a function. Let's take a look at it.

// 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;
}
 
// Retrieve the total number of records
Function getRowsCount (){
$ This-> getRes ($ this-> SQL _number );
$ Row = $ this-> getRows ();
$ This-> number = $ row [0];
Return $ this-> number;
}
 
// Obtain 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. = "[homepage]";
$ View. = "[Previous Page]";
} Else {
$ View. = "<a href =". $ url. "page = 1> [homepage] </a> ";
$ View. = "<a href =". $ url. "page =". ($ page-1). "> [Previous page] </a> ";
}
If ($ page <$ this-> pageCount ){
$ View. = "<a href =". $ url. "page =". ($ page + 1). "> [Next page] </a> ";
$ View. = "<a href =". $ url. "page =". $ this-> pageCount. "> [last page] </a> ";
} Else {
$ View. = "[Next Page]";
$ View. = "[last page]";
}
Return $ view. "current number ". $ page. "Page/total ". $ this-> pageCount. "page ". $ this-> number. "record ". "Go to ". $ this-> getUrl ($ url, $ page );
}
 
// Go to the page by page
Function getUrl ($ url, $ page ){
$ Go = "<input type =" text "size =" 2 "name =" page "value =" ". $ page." "class =" but01 "/> page
<Input type = "button" value = "GO" onclick = "location. href = '". $ url. "page =' + page. value"/> ";
Return $ go;
}
 
// Jump to the page
Function refUrl ($ url, $ speak ){
Print ("<script language = 'javascript '> ");
Print ("alert ('". $ speak ."');");
Print ("location. href = '". $ url ."';");
Print ("</script> ");
}
 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.