Paging function

xiaoxiao2021-03-06  61

// Define several global variables: // $ page: current page number; // $ firstcount: start items of queries; // $ PAGENAV: page navigation bar code, the function is not output inside; // $ _SERVER: Read this page URL "$ _ server [" Request_uri "]" must. Global $ Page, $ FIRSTCOUNT, $ PAGENAV, $ _ Server

/ / In order to access the "$ DISPLAYPG" here, it is also set to global variables. Note that a variable is redefined as a global variable, the original value is overwritten, so it is re-assigned here. $ Global ["displaypg"] = $ displaypg;

IF (! $ Page) $ Page = 1;

// If the $ URL uses the default, the null value, the value is this page URL: if (! $ URL) {@ $ URL = $ _ Server ["Request_uri"];}

// URL analysis: $ parse_url = parse_url ($ URL); @ $ url_query = $ parse_URL ["query"]; // Remove the URL query string IF ($ URL_QUERY) {// Because the URL may contain the page number Information, we have to remove it in order to add new page number information. // This is used here, please refer to "Regular Expression in PHP" (http://www.pconline.com.cn/pcedu/empolder/wz/php/10111/15058.html) $url_Query=REG_REPLACE ("(^ | &) Page = $ Page", "", $ URL_QUERY);

// Replace the query string of the original URL after processing: $ url = str_replace ($ PARSE_URL ["Query"], $ URL_QUERY, $ URL);

// After the URL adds Page query information, but to assign the value: if ($ URL_QUERY) $ URL. = "& Page"; Else $ URL. = "Page";} else {$ URL. = "Page";

// Table Calculation: $ lastpg = CEIL ($ TOTLE / $ DISPLAYPG); // Last page, the total number of pages $ Page = min ($ Lastpg, $ Page); $ prePg = $ PAGE-1; // Previous Page $ nextpg = ($ page == $ lastpg? 0: $ page 1); // Next $ firstcount = ($ PAGE-1) * $ displayPG; // Start Page Navigation Code: $ Pagenav = " Showing No. B> ". ($ TOTLE? ($ FIRSTCOUNT 1): 0)." - ". Min ($ FIRSTCOUNT $ DisplayPG, $ TOTLE)." record Total $ TOTLE record

// If only one page is jumped out of the function: IF ($ lastpg <= 1) Return False;

$ Pagenav. = " "; ELSE $ PAGENAV. =" Page "; if ($ nextpg) $ Pagenav. =" page "; Else $ Pagenav. =" Page "; $ PAGENAV. =" Last ""

// Drop the jump list, list all the page numbers: $ PAGENAV. = "To the