Ec (2); & lt; styletype & quot; textcss tutorial & quot; & gt; Code. pagecool ,. pagecoolselect ,. pagecoolpre ,. pagecoolnext ,. pageinfo ,. curtotalx ,. pagecoolprex ,. pagecoolnextx {float: left; height: 20px; font-script ec (2); script
! Function_exists ('cdstr') & exit ('foridden ');
Class wrzc_netpage {
Private $ page_name = "p ";
Private $ pagesize = 10; // number of records per page
Private $ total = 0; // The total number of records
Private $ pagebarnum = 10; // Number of bars.
Private $ totalpage = 0;
Private $ linkhead = ""; // url address header
Private $ current_pageno = 1; // current page
Public function _ construct ($ total, $ pagesize = 10 ){
If ((! Is_int ($ total) | ($ total <0) die ("total number of records error! ");
If ((! Is_int ($ pagesize) | ($ pagesize <0) die ("pagesize error! ");
$ This-> set ("total", $ total );
$ This-> set ("pagesize", $ pagesize );
$ This-> set ('totalpage', ceil ($ total/$ pagesize ));
}
Public function set ($ var, $ value ){
If (in_array ($ var, get_object_vars ($ this )))
$ This-> $ var = $ value;
Else {
Throw new pb_page_exception ("error in set ():". $ var. "does not belong to pb_page! ");
}
}
Public function get_linkhead (){
$ This-> set_current_page ();
If (empty ($ _ server ['query _ string']) {
$ This-> linkhead = $ _ server ['request _ uri ']. "? ". $ This-> page_name." = ";
} Else {
If (isset ($ _ get [$ this-> page_name]) {
$ This-> linkhead = str_replace ($ this-> page_name. '= '. $ this-> current_pageno, $ this-> page_name. '=', $ _ server ['request _ uri ']);
} Else {
$ This-> linkhead = $ _ server ['request _ uri '].' & '. $ this-> page_name.' = ';
}
}
}
/* Return the address value for the specified page */
Public function get_url ($ pageno = 1 ){
If (empty ($ this-> linkhead) $ this-> get_linkhead ();
Return str_replace ($ this-> page_name. '=', $ this-> page_name. '='. $ pageno, $ this-> linkhead );
}
/* Current page */
Public function set_current_page ($ current_pageno = 0 ){
If (empty ($ current_pageno )){
If (isset ($ _ get [$ this-> page_name]) {$ this-> current_pageno = intval ($ _ get [$ this-> page_name]);}
} Else {
$ This-> current_pageno = intval ($ current_pageno );
}
If ($ this-> current_pageno> $ this-> totalpage) header ("location:./"); // $ this-> current_pageno = 1
}
Public function set_format ($ str) {return $ this-> format_left. $ str. $ this-> format_right ;}
/* Obtain the "next page "*/
Public function next_page (){
If ($ this-> current_pageno <$ this-> totalpage ){
Return 'get _ url ($ this-> current_pageno + 1). '">'. $ this-> next_page .'';
}
Return '';
}
/* Obtain and display the "Previous Page "*/
Public function pre_page (){
If ($ this-> current_pageno> 1) {return 'get _ url ($ this-> current_pageno-1). '">'. $ this-> pre_page .'';}
Return '';
}
/* Obtain and display the "Homepage "*/
Public function first_page () {return 'get _ url (1). '">'. $ this-> first_page ."";}
/* Get the "Last page" displayed "*/
Public function last_page () {return 'get _ url ($ this-> totalpage). '">'. $ this-> last_page .'';}
Public function nowbar (){
If ($ this-> totalpage> 1 ){
$ Begin = $ this-> current_pageno-ceil ($ this-> pagebarnum/2 );
$ Begin = ($ begin> = 1 )? $ Begin: 1;
$ Return = '';
For ($ I = $ begin; $ I <$ begin + $ this-> pagebarnum; $ I ++ ){
If ($ I <= $ this-> totalpage ){
If ($ I! = $ This-> current_pageno ){
$ Return. = "get_url ($ I)." class = pagecool> ". $ I .'';
} Else {
$ Return. ='
'. $ I .'
';
}
} Else {
Break;
}
}
Unset ($ begin );
}
Return $ return;
}
/* "Previous Page "*/
Public function pre_bar (){
If ($ this-> current_pageno> ceil ($ this-> pagebarnum/2 )){
$ Pageno = $ this-> current_pageno-$ this-> pagebarnum;
If ($ pageno <= 0) $ pageno = 1;
Return $ this-> set_format ('get _ url ($ pageno). '">'. $ this-> pre_bar ."");
}
Return $ this-> set_format ('get _ url (1). '">'. $ this-> pre_bar ."");
}
/* "Next page "*/
Public function next_bar (){
If ($ this-> current_pageno <$ this-> totalpage-ceil ($ this-> pagebarnum/2 )){
$ Pageno = $ this-> current_pageno + $ this-> pagebarnum;
Return $ this-> set_format ('get _ url ($ pageno). '">'. $ this-> next_bar ."");
}
Return $ this-> set_format ('get _ url ($ this-> totalpage). '">'. $ this-> next_bar ."");
}
/* Jump */
Public function select (){
$ Return =' ';For ($ I = 1; $ I <= $ this-> totalpage; $ I ++ ){If ($ I ==$ this-> current_pageno ){$ Return. =''. $ I .'';} Else {$ Return. =''. $ I .'';}}$ Return. ='';
Return $ return;
}
Public function pagebar ($ mode = 1 ){
Global $ global;
$ This-> set_current_page ();
$ This-> get_linkhead ();
// Return ("Total
". $ This-> total ."Records. ");
Switch ($ mode ){
Case 1:
$ This-> pre_page = '';
$ This-> next_page = '';
Return $ this-> pre_page (). $ this-> nowbar (). $ this-> next_page ().'
Page '. $ this-> current_pageno.'/total '. $ this-> totalpage .'
';
Break;
Case 2:
$ This-> pre_page = '';
$ This-> next_page = '';
Return'
'. $ This-> current_pageno.'/'. $ this-> totalpage .'
'. $ This-> pre_page (). $ this-> next_page ();
// Return'
'. $ This-> total.'/'. $ this-> current_pageno.'/'. $ this-> totalpage .'
'. $ This-> pre_page (). $ this-> next_page ();
Break;
Case 3:
$ This-> pre_page = '';
$ This-> next_page = '';
Return'
Page '. $ this-> current_pageno.'/total '. $ this-> totalpage .'
'. $ This-> pre_page (). $ this-> next_page ();
Break;
}
}
}
?>
Code 2
! Function_exists ('cdstr') & exit ('foridden ');
Class uobarpage {
Private $ page_name = "p"; // page tag, used to control url pages. For example, xxx. php? Pb_page = pb_page in 2
Private $ pagesize = 10; // number of records per page
Private $ total = 0; // The total number of records
Private $ pagebarnum = 10; // control the number of records.
Private $ totalpage = 0; // total number of pages
Private $ linkhead = ""; // url address header
Private $ current_pageno = 1; // current page
/**
* Display symbol settings
*/
Private $ next_page = '>'; // next page
Private $ pre_page = '<'; // Previous Page
Private $ first_page = 'first'; // Home Page
Private $ last_page = 'lalala'; // the last page.
Private $ pre_bar = '<'; // The last page
Private $ next_bar = '>'; // next page
Private $ format_left = '[';
Private $ format_right = ']';
Public function _ construct ($ total, $ pagesize = 10 ){
If ((! Is_int ($ total) | ($ total <0) die ("total number of records error! ");
If ((! Is_int ($ pagesize) | ($ pagesize <0) die ("pagesize error! ");
$ This-> set ("total", $ total );
$ This-> set ("pagesize", $ pagesize );
$ This-> set ('totalpage', ceil ($ total/$ pagesize ));
}
Public function set ($ var, $ value)
{
If (in_array ($ var, get_object_vars ($ this )))
$ This-> $ var = $ value;
Else {
Throw new pb_page_exception ("error in set ():". $ var. "does not belong to pb_page! ");
}
}
/**
* Get the default url to get the specified url address
*
*/
/*
Public function get_linkhead (){
$ This-> set_current_page ();
$ This-> linkhead = $ _ server ['php _ self ']. "? ". $ This-> page_name." = ";
}
*/
Public function get_linkhead (){
$ This-> set_current_page ();
If (empty ($ _ server ['query _ string']) {
$ This-> linkhead = $ _ server ['request _ uri ']. "? ". $ This-> page_name." = ";
} Else {
If (isset ($ _ get [$ this-> page_name]) {
$ This-> linkhead = str_replace ($ this-> page_name. '= '. $ this-> current_pageno, $ this-> page_name. '=', $ _ server ['request _ uri ']);
} Else {
$ This-> linkhead = $ _ server ['request _ uri '].' & '. $ this-> page_name.' = ';
}
}
}
/**
* Return the address value for the specified page.
*/
Public function get_url ($ pageno = 1)
{
If (empty ($ this-> linkhead) $ this-> get_linkhead ();
Return str_replace ($ this-> page_name. '=', $ this-> page_name. '='. $ pageno, $ this-> linkhead );
}
/**
* Set the current page
*
*/
Public function set_current_page ($ current_pageno = 0 ){
If (empty ($ current_pageno )){
If (isset ($ _ get [$ this-> page_name]) {
$ This-> current_pageno = intval ($ _ get [$ this-> page_name]);
}
} Else {
$ This-> current_pageno = intval ($ current_pageno );
}
If ($ this-> current_pageno> $ this-> totalpage) header ("location :. /"); // $ this-> current_pageno = 1 ////////////
}
Public function set_format ($ str ){
Return $ this-> format_left. $ str. $ this-> format_right;
}
/**
* Get the code that displays the next page.
*
* @ Return string
*/
Public function next_page (){
If ($ this-> current_pageno <$ this-> totalpage ){
Return 'get_url ($ this-> current_pageno + 1). '">'. $ this-> next_page .'';
}
Return '';
}
/**
* Get the code for displaying the "Previous Page"
*
* @ Return string
*/
Public function pre_page (){
If ($ this-> current_pageno> 1 ){
Return 'get _ url ($ this-> current_pageno-1). '">'. $ this-> pre_page .'';
}
Return '';
}
/**
* Get the code for displaying the "Homepage"
*
* @ Return string
*/
Public function first_page (){
Return 'get _ url (1). '">'. $ this-> first_page ."";
}
/**
* Get the code for displaying the "Last page"
*
* @ Return string
*/
Public function last_page (){
Return 'get _ url ($ this-> totalpage). '">'. $ this-> last_page .'';
}
// Gyl1
Public function nowbar (){
$ Begin = $ this-> current_pageno-ceil ($ this-> pagebarnum/2 );
$ Begin = ($ begin> = 1 )? $ Begin: 1;
$ Return = '';
For ($ I = $ begin; $ I <$ begin + $ this-> pagebarnum; $ I ++)
{
If ($ I <= $ this-> totalpage ){
If ($ I! = $ This-> current_pageno)
$ Return. = 'get_url ($ I). '"> '.''. $ I .''.'';
Else
$ Return. =''. $ I .'';
} Else {
Break;
}
}
Unset ($ begin );
Return $ return;
}
/**
* Obtain the code for displaying the "Previous Page"
*
* @ Return string
*/
Public function pre_bar ()
{
If ($ this-> current_pageno> ceil ($ this-> pagebarnum/2 )){
$ Pageno = $ this-> current_pageno-$ this-> pagebarnum;
If ($ pageno <= 0) $ pageno = 1;
Return $ this-> set_format ('get _ url ($ pageno). '">'. $ this-> pre_bar ."");
}
Return $ this-> set_format ('get _ url (1). '">'. $ this-> pre_bar ."");
}
/**
* Get the code for displaying "next page"
*
* @ Return string
*/
Public function next_bar ()
{
If ($ this-> current_pageno <$ this-> totalpage-ceil ($ this-> pagebarnum/2 )){
$ Pageno = $ this-> current_pageno + $ this-> pagebarnum;
Return $ this-> set_format ('get _ url ($ pageno). '">'. $ this-> next_bar ."");
}
Return $ this-> set_format ('get _ url ($ this-> totalpage). '">'. $ this-> next_bar ."");
}
/**
* Get the code for displaying the jump button
*
* @ Return string
*/
Public function select ()
{
$ Return ='';For ($ I = 1; $ I <= $ this-> totalpage; $ I ++){If ($ I ==$ this-> current_pageno ){$ Return. =''. $ I .'';} Else {$ Return. =''. $ I .'';}}$ Return. ='';
Return $ return;
}
/**
* Obtain the limit value in the mysql tutorial statement.
*
* @ Return string
*/
Public function limit2 (){
// Return ("Total". $ This-> total ."Records. ");
// Return ('total. $ this-> total. 'records. '. $ This-> current_pageno). "Page/total". $ this-> totalpage.' ';
Return ('total'. $ This-> current_pageno.'/'. $ this-> totalpage .'Page ');
}
Public function pagebar ($ mode = 1)
{Global $ global;
$ This-> set_current_page ();
$ This-> get_linkhead ();
Switch ($ mode)
{
Case '1 ':
$ This-> next_page = '';
$ This-> pre_page = '';
Return $ this-> pre_page (). $ this-> nowbar (). $ this-> next_page ();
// Return $ this-> pre_page (). $ this-> nowbar (). $ this-> next_page (). 'di '. $ this-> select (). 'page ';
Break;
}
}
}
?>