A class displayed by a paging when learning PHP

zhaozj2021-02-17  53

This class needs to open the corresponding database before calling. This kind of almost all functions, homepage, topping, next page, last page, jump, front, then turning the page, jump, front, the next page, the last page, the column is displayed, the output text color, the background color, you can set it yourself call easy to use, now write for your reference class file page.php file .page.inc test page is displayed first need to create a database, here is the sale of used: masters email: xyy_003@163.com/** ***************************************** The following is all this paging class Attributes:***********************************************/ VAR $ maxline; / / per page Display line number var $ maxpage; // Directive VAR $ OFFSET; // Record the offset Var $ TOTAL; // Record Total Var $ Result; // Read Result VAR $ TPAGES; / / Total number VAR $ CPAGES; // Current page number var $ SQL; // will be executed SQL statement var $ pageQuery; // Page display to pass the parameter var $ output; // output content VAR $ textsize; // Output size VAR $ textColor; // Output color var $ inbdrcolor; // Output text box Border color var $ inbgcolor; // Output text box Background color / ***** **************************************** The following is all methods of this paging class: * ****************************************************** / constructor Page ($ SQL, $ ML, $ MP, $ TS, $ TC, $ INBDRC, $ INBGC) Parameters: Query SQL statement, maximum line number, number of page numbers per output, output text size, text color, input box Border primary color, input box background original color setting Transfer parameter setPageQuery: Parameter name, parameter value read record, display output showlist ($ StartPage, $ T, $ OF, $ PHP_SELF) Parameters: Output page number Minimal, what kind of way jump flag, data record set offset, current file name This section does not need to give a value, you only need to extend the following variable name when calling Page.inc class file

************************************************************************************************************************************************************************* / CLASS PAGE {var $ maxline; / / per page Display line number var $ maxpage; // Display the number of parties VAR $ OFFSET; // Record the offset Var $ TOTAL; // Record Total VAR $ Result; // Read Results VAR $ TPAGES; / / Total number VAR $ CPAGES; // Current page number var $ sql; // The SQL statement VAR $ pageQuery to be executed; // Page display to pass the parameter var $ OTPUT; / / output Content VAR $ TEXTSIZE; / / Output Size Var $ TEXTCOLOR; / / Output Color Var $ InBdrcolor; // Outputs Border Color Var $ InBgcolor; // Output Text Box / **** ** Constructor ************* Parameters: Query SQL statement, maximum number of lines, number of page numbers per output, output text size, text color, input frame Box Box, Input Box Background Original color ********************************************** / Function Page ($ SQL, $ ML, $ MP, $ TS, $ TC, $ INBDRC $ INBGC) {$ this-> SQL = URLDECode ($ SQL); $ this-> SQL = Stripslashes ($ this-> SQL); $ this-> maxline = ml; $ this-> maxpage = $ mp; $ this-> textsize = $ TS; $ this-> textcolor = $ tc; $ this-> inbdrcolor = $ inbdrc; $ this-> inbgcolor = $ inbgc;} // ****** Set delivery parameters ** ********* Function setPagePara ($ key, $ value) {$ tmp [key] = $ key; $ THIS-> PageQuery [] = $ TMP;} / ******** Read record, display output ************** parameter: output page number, how to jump, data record set Offset, the current file name This part of the parameters do not require a given value, only the following variable name is only available when calling, *********************************** *************** / FUN Ction showlist ($ StartPage, $ T, $ OF, $ PHP_SELF) {IF ($ Of == ") $ of = 0; $ this-> offset = $ = $ = $ == /; // Determine this offset $ querysql = $ this-> sql; // division determine the start value IF ($ T == 1) {$ startpage = $ startpage $ this-> offset = ($ startPAGE-1) * $ THIS-> Maxline;} IF ($ T == 2) {$ StartPage = $ StartPage- $ THIS-> MaxPage; IF ($ StartPage <1) {$ StartPage = 1;} $ this-> offset = $ startPage-1) * $ this-> maxline;} if ($ t == 3) {$ this-> offset = ($ startPage-1) * $ this-> maxline;} if ($ StartPage <1 or $ STARTPAGE <1 OR $ STARTPAGE == "" "$ startPage = 1; // Calculate the number of records of this query worth $ Result =

MySQL_Query; $ this-> total = mysql_num_rows ($ result); // Put the data of the current page to the corresponding attribute of this class, easy to use $ SQLLIMIT = "Limit" when calling. $ this-> offset ". $ this-> maxline; $ this-> Result = mysql_query ($ querysql. $ sqllimit); $ this-> tpages = CEIL ($ this-> Total / $ this-> maxline); $ this- > Cpages = $ this-> offset / $ this-> maxline 1; $ querysql = urlencode ($ this-> SQL); // Determine the output content, and pay the corresponding attribute of this class.

$ this-> Output =

Offset & querysql = $ querysql> textsize; color: $ this-> textcolor / ">> THIS-> TPAGES." page / item cpages. "/" Style = / "border: $ this-> Inbdrcolor 1pt Solid; Background-Color: $ this-> Inbgcolor Height: 12pt; Text-Align: Center; Color: $ this-> textcolor / "> textsize; color: $ this-> textcolor / "> page & NBSP / N "; $ this-> output. =" "; $ k = count ($ this-> pagequery); / / Generate parameter string or hidden text domain $ strquery = ""; for ($ i = 0; $ i <$ 1) {$ STRQUERY. = "&". $ This-> PageQuery [$ i] [key]. "=" $ this-> pageQuery [$ I] [value]; $ this-> output. = " PageQuery [$ I] [key]. "/" Value = ". $ This-> value]."> ";} If ($ startpage> 1) {$ this-> Output. =" Textsize; color: $ this-> textcolor /"> [ textcolor; text-decoration: none /"> <<< / a>] ;} for ($ I = $ startpage; $ I <= $ this-> tpages; $ i ) {$ offset = ($ I-1) * $ this->

$ This-> output. = " textsize; color: $ this-> textcolor / "> [ textcolor; text-decoration: none /">""" "" "; if ($ I- $ StartPage) > $ this-> maxpage-2 and $ i! = $ this-> tpages) {$ this-> Output. = " textsize; color: $ this-> TextColor / "> [ Offset & querysql = $ querysql & startpage = $ startpage & t = 1 $ strQuery style = /" color: $ this-> TextColor; text-decoration: none / ">> > ] "; Break;}} $ this-> output. =" ";} // ****** End class}?> / ***** ***************************************** The following is an example of applying a word class *** ***************************************************** / SetPagePara ("Para", "Paravalue"); // Settings to pass the parameters, if there are multiple calls a few times $ PCLASS-> Showlist ($ StartPage, $ T, $ OFFSET, $ PHP_SELF); // Generate output content, pay it to the corresponding attribute Echo $ PCLASS-> OUTPUT; / / Output content // Output the data of the current page ($ DATE = mysql_fetch_row ($ PCLASS-> Result)) {Echo "$ DATE [1] | $ DATE [2] | $ DATE [3]
";}?> http://coolslob.fykj.com/favorites/9cbs2rd/408753.htm

转载请注明原文地址:https://www.9cbs.com/read-28475.html

New Post(0)