I am a newbie with regards to the paging of PHP. please teach me how to use PHP to view the paging function of data. thank you. check this page and note it. if you don't understand it, take it and try again with the refer. PHPcodepub's paging problem about PHP
I am a newbie. please advise me how to use PHP to view data pages. thank you.
------ Solution --------------------
Look at this page, there is a comment, don't understand it, take it down and use it again
Http://www.jb51.net/article/27813.htm
------ Solution --------------------
Here is an example. this is also being completed recently.
PHP code
Public static function getuser (CleanRequest & $ clean) {Registry: set ('clean', $ clean); // print_r (Registry: get ('clean ')); die (); // print_r (Registry: get (); $ user = $ clean-> get ('user'); if ($ user) $ where. = ($ where? 'AND': 'where '). 'admin_name like \ '% '. $ user. '% \ ''; $ db = new MysqlDB (); $ sql1 =" select * from admin "; $ result = $ db-> query ($ sql1 ); $ count = $ db-> num_rows ($ result); $ pagesize = 5; if ($ page = $ clean-> get ('page ')) {$ page = intval ($ page);} else {$ page = 1 ;}$ pagecount = ceil ($ count/$ pagesize); $ limit = $ page-1; // if ($ where) $ SQL = "select * from admin ". $ where. "limit ". $ limit * $ pagesize. ", $ pagesize"; $ r = $ db-> select ($ SQL); foreach ($ r as $ v) {$ html. =''. $ V ['admin _ id'].''. $ V ['admin _ name'].''. $ V ['admin _ pwd'].'Delete';}/* For ($ I = 1; $ I <= $ pagecount; $ I ++) {// numeric paging if ($ I! = $ Page) $ html. = "$ I"; else $ html. = "". $ I; * //} if ($ count> $ pagesize) {/* if ($ page = 1) {// if the page number has only one page $ html. = 'homepage | previous page';} * // else {$ html. =''; If ($ page> 1) {$ html. = 'homepage | previous page | ';} if ($ page = $ pagecount | $ pagecount = 0) {// if the current page is equal to the total number of pages $ html. = 'next page | last page';} else {$ html. = 'next page | last page'; }}$ html. = 'col '. $ count. 'records per page '. $ pagesize. 'items col '. $ pagecount. 'page'; Return $ html ;}
------ Solution --------------------
On the fifth floor, I gave you a clear idea. I also gave you an object-oriented method.
Require_once 'DB. php ';
Session_start ();
$ Pagesize = 5; // The size of each page.
$ Page = $ _ GET ["page"];
If ($ page = "") {// if no page is set, the default value is 1.
$ Page = 1;
}
$ SQL = "select * from st_info order by ID desc limit". ($ pagesize * ($ page-1). ",". $ pagesize;
$ Query = mysql_query ($ SQL); // display the number to the number
$ Quer2 = mysql_query ("select * from st_info ");
$ Num = mysql_num_rows ($ quer2); // you can specify the number of all rows.
$ Pagecount = ceil ($ num/$ pagesize); // how many pages should be displayed
If ($ pagecount = 0 ){
Echo "sorry, it's null ";
} Else {
If (mysql_num_rows ($ query) = 0 ){
Echo "sorry ,";
}
}
?>
Total Page, Display per page Information, Total Data entries. For ($ I = 1; $ I <= $ pagecount; $ I ++ ){Echo'$ I"; |