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> ");
}