PHP simple paging class

PageClass.php

  Total = $ TOTAL; $ this-> size = $ size; $ this-> pagecount = CEIL ($ TOTAL / $ Size); $ this-> currentpage = $ currentpage; $ this-> Pagestart = $ this-> currentpage- $ this-> showpages; $ this-> pageend = $ this-> currentpage + $ this-> showpages; // The start page size is less than 1, set to 1 IF ($ this-> Pagestart  pageend = $ this-> pageend + (1- $ this-> pagestart); $ this-> Pagestart = 1;} // If End page greater than the total number of pages, reset end page = total page number if ($ this-> pageend> = $ this-> pagecount) {// difficult ($ this-> PageCount  showpages * 2 + 1) {$ this-> Pagestart = 1;} else {$ this-> Pagestart = $ THIS-> Pagestart - ($ this-> pageend- $ this-> pagecount);} $ this-> pageend = $ this-> Pagec{$ Str = ''; $ str. = $ this-> Home (); $ str. = $ this-> lastpage (); $ STR. = $ THIS- > Numpage (); $ Str. = $ THIS-> NextPage (); $ str. = $ this-> last (); $ str. = $ this-> counttotal (); $ str. = '' RETURN $ STR;} // Home Private function home () {i ($ this-> currentpage == 1) {$ str = '
Home
';} else {$ Str = '

Home

';} RETURN $ Str;} // Previous PRIVATE FUNCTION LASTPAGE () {i ($ this-> currentpage == 1) {$ Str =' Previous '; } else {$ str = '

currentpage-1).'> Previous

';} Return $ str;} // Middle Digital Function Numpage () {$ Str= ' ... '; for ($ I = $ this-> Pagestart; $ i

pageend; $ i ++) {= ($ i == $ this-> currentpage) {$ STR = '

'. $ I. '';} else {$ Str. = ''. $ I. '';}} $ Str. = '. .. '; RETURN $ STR;} // Next PRIVATE FUNCTION NEXTPAGE () {IF ($ this-> CurrentPage == $ this-> pagecount) {$ str ='

Next

';} else {$ str ='

currentpage + 1). '> Next page

';} RETURN $ STR;} // Last Function Last () {IF ($ this- > currentPage == $ this-> pagecount) {$ str = ' ELSE {$ str =' pagecount. '> Last page

';} Return $ STR } // Statistics Private Function CountoTal () {return '

Total 13 Bar data

';}}

call Page.php
GetMessage (); $ sql = ‘select * from student’; $ stmt = $ db-> prepare ($ sql); $ STMT-> execute (); // Get the total number of people $ Total = $ stmt-> rowcount (); $ size = 5; // Each page number 0, 8; 8, 8 16, 8 // If there is no First, the default is the first page isset ($ _ get [‘Page’])? $ CurrentPage = $ _GET [‘Page’]: $ CURRENTPAGE = 1; $ SQL. = “Limit”. ($ CURRENTPAGE-1) * $ SIZE. “, $ SIZE”; $ stmt = $ db-> prepare ($ SQL); $ stmt-> execute (); // Query result set $ res = $ stmt-> fetchall (pdo :: fetch_assoc)

Document
 p {margin: 0} #page {height: 40px; padding: 20px 0px;} #page a {display: BLOCK; FLOAT: LEFT; Margin-Right: 10px; Padding: 2px 12px;Height: 24px; border: 1px #ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc Solid; Background: None; color: # 808080; font-size: 12px; line-height: 24px;} #page A: Hover {Color: # 077ee3 Border: 1px # 077ee3 solid;} #page a.cur {border: none; background: # 43badb; color: #fff;} #page p {float: Left; padding: 2px 12px; font-size: 12px; height : 24px; line-height: 24px; color: #bbb; border: 1px #cccfcfc; margin-right: 8px;} #page p.pageremark {border-style: none; background: none; margin -Right: 0px; Padding: 4px 0px; color: # 666;} #page p.pageremark b {color: red;} #page p.pagellipsis {border-style: none; background: none; padding: 4px 0px; color : # 808080;}    '; echo'   ID   Name   EMAI   mobile phone number  '; Foreach ($ RES AS $ K => $ V) {Echo'  <?php

    echo ' '. $ V [' ID '].'  ';} echo' 
'].' '. $ V [' email '].' '. $ V [' Mobile '].' '; $ Page = New page ($ TOTAL, $ SIZE, $ CurrentPage); Echo $ page-> pages ();?>
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment