Phpmysql paging implementation code. This is a perfect paging class. it supports form input jump, select jump paging, and 10 pages offset paging. * This is a perfect paging class. it supports form input jump, select jump paging, and 10 pages, offset pagination on the next 10 pages. */
This is a perfect paging class. it supports form input jump, select jump paging, and 10 pages offset paging.
*/
Class wind_page
{
Var $ page;
// Current page
Var $ total;
// The total number of records
Var $ totalpage;
// Total page tree
Var $ pagesize;
// Number of entries per page
Var $ offset;
// Offset
Var $ result;
// Record set
Var $ thispage;
// The total number of records
Var $ link;
// Connect (record $ _ get variable)
Var $ bar_mun;
// Number of pages displayed on the bar
Var $ starttime;
// Start time
Var $ bar_last;
// The number of consecutive pages of the navigation bar
Var $ bar_mid;
// Navigation bar middle page
Var $ minpage;
// Minimum navigation bar Page
Var $ maxpage;
// Maximum page of the navigation bar
Var $ key;
// Identify pages (use and distinguish multiple pages on one page)
Var $ style;
// Output style
Var $ pre_page_char;
// Previous Page
Var $ pre_page_image;
// Previous page graphics
Var $ pre_page_char_color;
// The font color of the previous page
Var $ next_page_char;
// Next page
Var $ next_page_image;
// Next page
Var $ next_page_char_color;
// Font color of the next page
Var $ pre_groud_char;
// Flip the intermediate page number
Var $ pre_groud_char_color;
// Font color of the top pages
Var $ next_groud_char;
// Number of intermediate pages to be flipped down
Var $ next_groud_char_color;
// Font color of the number of pages to flip down
Var $ first_page_char;
// Homepage
Var $ first_page_char_color;
// Homepage font color
Var $ last_page_char;
// Last Page
Var $ last_page_char_color;
// Font color of the last page
Var $ html_page_val;
// Current page number of html
Function wind_page ($ SQL, $ pagesize = 20, $ bar_mun = 10, $ style = 1, $ this_page = 1, $ html_page_val = 1, $ key = "") // Constructor ()
{
$ This-> starttime = microtime ();
$ This-> pagesize = $ pagesize;
// Number of entries per page
$ This-> key = trim ($ key );
$ This-> bar_mun = $ bar_mun;
$ This-> style = $ style;
$ This-> html_page_val = $ html_page_val;
// Current page number of html
$ This-> bar_last = $ bar_mun-1;
$ This-> bar_mid = floor ($ bar_mun/2 );
$ This-> SQL = $ SQL;
$ Result = mysql tutorial _ query ($ this-> SQL );
$ This-> total = mysql_num_rows ($ result );
// The total number of records
$ This-> totalpage = ceil ($ this-> total/$ this-> pagesize );
// Total number of pages
// $ This-> page = ceil ($ _ get [$ this-> key. "page"]);
$ This-> page = $ this_page;
// Current page
If ($ this-> page = "" | $ this-> page <1 |! Is_numeric ($ this-> page) $ this-> page = 1;
$ This-> page = min ($ this-> page, $ this-> totalpage );
$ This-> thispage = $ this-> pagesize;
If ($ this-> page * $ this-> pagesize> $ this-> total ){
$ This-> thispage = $ this-> total-($ this-> page-1) * $ this-> pagesize;
};
$ This-> SQL. = "limit". ($ this-> pagesize * ($ this-> page-1). ",". $ this-> pagesize;
// Number of records that start reading
// Echo"
";
$ This-> result = mysql_query ($ this-> SQL );
$ This-> getvar ();
$ This-> pre_page_char = "previous page ";
$ This-> pre_page_image = "";
$ This-> next_page_char = "next page ";
$ This-> next_page_image = "";
$ This-> pre_groud_char = "previous Group ";
$ This-> next_groud_char = "Next Group ";
}
Function getvar () // gets get variables other than page
{
$ This-> link = "";
Foreach ($ _ get as $ key => $ vaule ){
If (strtolower ($ key )! ==$ This-> key. "page") $ this-> link. = "& $ key = $ vaule ";
}
}
Function pre_page ($ color = "#909090", $ sign = 0) // Previous Page
{
If ($ this-> page> 1 ){
Return "page-1).". html "class =" AB "> pre_page_char_color." ">". $ this-> pre_page_char ."";
} Else
{
Return "". $ this-> pre_page_char ."";
}
}
Function next_page ($ color = "#909090", $ sign = 0) // Next page
{
If ($ this-> page <$ this-> totalpage ){
Return "page + 1).". html "class =" AB ">". $ this-> next_page_char ."";
} Else {
Return "". $ this-> next_page_char ."";
}
}
Function pre_groud ($ char = "<", $ color = "#909090") // the previous group
{
If ($ this-> page <= ($ this-> bar_mid + 1 )){
Return "". $ this-> pre_groud_char ."";
// Return $ this-> pre_groud_char;
} Else {
$ Pre_gpage = ($ this-> page-$ this-> bar_mid <0 )? 1:
$ This-> page-$ this-> bar_mid;
Return "". $ this-> pre_groud_char ."";
}
}
Function next_groud ($ char = ">", $ color = "#909090") // The next group
{
If ($ this-> totalpage-$ this-> page) <= ($ this-> bar_mid-1 )){
Return "". $ this-> next_groud_char ."";
} Else {
$ Next_gpage = ($ this-> page + $ this-> bar_mid <$ this-> totalpage )? $ This-> page + $ this-> bar_mid:
$ This-> totalpage;
Return "". $ this-> next_groud_char ."";
}
}
Function mun ($ lcolor = "# ff6633", $ acolor = "# ff6633", $ left = "", $ right = "") // digital navigation bar
{
$ Link = "";
$ This-> minpage = ($ this-> page-$ this-> bar_mid <1 )? 1 :( $ this-> page-$ this-> bar_mid );
$ This-> maxpage = $ this-> minpage + $ this-> bar_last;
If ($ this-> maxpage> $ this-> totalpage ){
$ This-> maxpage = $ this-> totalpage;
$ This-> minpage = ($ this-> maxpage-$ this-> bar_last <1 )? 1: $ this-> maxpage-$ this-> bar_last;
}
For ($ I = $ this-> minpage; $ I <= $ this-> maxpage; $ I ++)
{
/* Page number of the cyclic output */
$ I = sprintf ("% 02d", $ I );
// Add 0 for the first two digits
$ Char = $ left. $ I. $ right;
// Narrow the left and right sides of the navigation bar
If ($ I ==$ this-> page)
{
/* If it is the current page, no link is added */
$ Link. = "". $ char ."";
}
Else
{
// $ Link. = "key." page = ". $ I. $ this-> link." ">". $ char ."";
$ Link. = "". $ char ."";
// Key: Add $ link after adding new materials
}
}
Echo"
";
Return $ link;
}
Function jump_bar ($ class = "jump_bar") // drop-down jump
{
$ Link ="";For ($ I = $ this-> minpage; $ I <= $ this-> maxpage; $ I ++ ){If ($ I <10) $ I = "0". $ I;// The number of definitions cannot exceed 10If ($ this-> page = $ I){/* Select the current page number */$ Link. ="Page ". $ I ."";}Else{$ Link. ="Page ". $ I ."";}}$ Link. ="";
Return $ link;
}
Function mun_bar () // the entire digital navigation bar [<] [<] [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [>] [>]
{
// Return $ this-> first_groud (). $ this-> pre_groud (). $ this-> pre_page (). $ this-> mun (). $ this-> next_page (). $ this-> next_groud (). $ this-> last_groud ();
Return $ this-> pre_groud (). "". $ this-> pre_page (). $ this-> mun (). $ this-> next_page (). "". $ this-> next_groud ();
}
Function page_button ()
{// The entire digital navigation bar [<] [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [>]
// Return $ this-> first_groud (). $ this-> pre_groud (). $ this-> pre_page (). $ this-> mun (). $ this-> next_page (). $ this-> next_groud (). $ this-> last_groud ();
Return $ this-> pre_page ('#909090', 1). $ this-> mun (). $ this-> next_page ('#909090', 1 );
}
Function total_bar ($ coloro = "#000000", $ colorn = "red") // Statistics page: 1/4310 page: 20 total: 4310 page: 20
{
Return "page times: $ this-> page/$ this-> totalpage each page: $ this-> pagesize total: $ this-> totalpage this page: $ this-> thispage ";
}
// The entire navigation bar
// Page times: 1/4310 per page: 20 total: 4310 page: 20 [<] [<] [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [>] [>]
Function page_bar ($ coloro = "#000000", $ colorn = "red "){
Return"
|
". $ This-> total_bar ()." |
". $ This-> mun_bar ()." |
". $ This-> jump_bar ()." |
|
". $ This-> mm_jumpmenu ();
}
Function taketime ($ color = "#000000") // calculates the execution time
{
Return"
Execution time on this page ". abs (microtime ()-$ this-> starttime) * 1000)." millisecond
";
}
Function style () // output pagination style
{
$ Style_num = $ this-> style;
If ($ this-> totalpage! = 0) // if the total number of pages is 0, no page is displayed.
{
Switch ($ style_num ){
Case 1:
Return $ this-> page_bar ();
// Page times: 1/4310 per page: 20 total: 4310 page: 20 [<] [<] [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [>] [>]
Break;
Case 2:
Echo $ this-> mun_bar ();
// The entire digital navigation bar [<] [<] [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [>] [>]
Break;
Case 3:
Echo $ this-> page_button ();
// The entire digital navigation bar [<] [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [>]
Break;
}
}
}
Function mm_jumpmenu () // webpage effect jump
{
// Window. open (selobj. options [selobj. selectedindex]. value, targ );
Return"