PHP paging. Today, I wrote a PHP paging processing script in my spare time. thank you !!! Display page index. php pagination function showbbsProcess. php author :. $ arr [$ I] [poster] .. at the time of release, I wrote a PHP paging processing script in my spare time today. please click it !!! Display page index. php
Pagination function showbbsProcess. php
'; // If the elements in the $ arr array are traversed, that is, $ I (starting from 0) equals to the number of elements in the array minus one, then it jumps out of the 2-layer loop (for loop and foreach loop) if ($ I = (count ($ arr)-1) break 2 ;}} $ RowCount = getRowCount ($ connectmysql); // total number of records $ PageCount = ceil ($ RowCount/$ PageSize); // total number of pages, ceil () function returns an integer echo 'post statistics :'. $ RowCount. 'string '. ''. 'total '. $ PageCount. 'Page'; // when the first page is displayed, the "previous page" if ($ CurrentPageID! = 1) {echo "previous page";} // forward jump page if ($ CurrentPageID> 2) {echo "<" ;}// output the detailed page number, for example: [1] for ($ j = 1; $ j <= $ PageCount; $ j ++) {echo "[$ j]";} // jump back to the page if ($ CurrentPageID <= ($ PageCount-2) {echo ">>> ";} // when the last page is displayed, the "next page" if ($ CurrentPageID! = $ PageCount) {echo "next page" ;}$ connectmysql-> closeConn ();}
Showbbs_fun.php
GetRowsArray ($ SQL); return $ arr1;} // This function is used to query the number of rows in a database table. function getRowCount ($ connectmysql) {$ SQL = "select * from db_content "; $ num = $ connectmysql-> getRowsNum ($ SQL); return $ num ;}
Database Class connectMysql. php
Conn = mysql_connect ($ this-> host, $ this-> username, $ this-> password); @ mysql_select_db ($ this-> dbname, $ this-> conn ); mysql_query ('set names utf-8 ');} // query result function getResult ($ SQL) {if ($ this-> conn = '') {$ this-> conndb () ;}$ this-> result = mysql_query ($ SQL, $ this-> conn );} // return the number of queried Records function getRowsNum ($ SQL) {$ this-> getResult ($ SQL); $ num_rows = mysql_num_rows ($ this-> result ); if (mysql_errno () = 0) {return $ num_rows;} else {return '';}} // output the result as a single record array and return function getArray ($ SQL) {$ this-> getResult ($ SQL); if (mysql_errno () = 0) {$ this-> resultArray = mysql_fetch_array ($ this-> result, MYSQL_ASSOC); // Get the associated array return $ this-> resultArray;} else {return '';}} // returns a two-dimensional array containing multiple records. function getRowsArray ($ SQL) {$ this-> getResult ($ SQL); if (mysql_errno () = 0) {while ($ row = mysql_fetch_array ($ this-> result, MYSQL_ASSOC) {$ this-> rowsArray [] = $ row;} return $ this-> rowsArray; // print_r ($ this-> rowsArray); exit;} else {return '';}// update, add, and delete function uidresult ($ SQL) {if ($ this-> conn = '') {$ this-> conndb ();} // echo $ SQL; // exit; @ mysql_query ($ SQL ); $ this-> rowsNum = @ mysql_affected_rows (); if (mysql_errno () = 0) {return $ this-> rowsNum;} else {return '';}} // release the result set function freeResult () {mysql_free_result ($ this-> result); $ this-> rowsNum = 0; $ this-> rowsArray = ''; $ this-> resultArray = '';} // closes the database function closeConn () {$ this-> freeResult (); mysql_close ($ this-> conn ); $ this-> conn = '';}}
SUCCESS !!! Display the page index. php paging handler function showbbsProcess. php author: '. $ arr [$ I] ['poster']. '''.' at the time of release...