Php paging function. Php paging function php Tutorial paging function $ connmysql tutorial _ connect (localhost, root, 123456); $ pagesize4; set the number of records displayed on each page mysql_select_db (ly, $ conn ); $ rsmysql_query (php paging function
Php Tutorial paging functions
$ Conn = mysql tutorial _ connect ("localhost", "root", "123456 ");
$ Pagesize = 4; // set the number of records displayed on each page
Mysql_select_db ("ly", $ conn );
$ Rs = mysql_query ("select count (*) from lyb", $ conn); // get the total number of records $ rs, used to calculate the total number of pages
$ Myrow = mysql_fetch_array ($ rs );
$ Numrows = $ myrow [0];
$ Pages = intval ($ numrows/$ pagesize); // calculate the total number of pages
If ($ numrows % $ pagesize)
$ Pages ++;
// Set the page number
If (isset ($ _ get ['Page']) {
$ Page = intval ($ _ get ['Page']);}
Else {
// Set it to the first page
$ Page = 1;
}
// Calculate the record offset
$ Offset = $ pagesize * ($ page-1 );
// Read the specified number of records
$ Rs = mysql_query ("select * from lyb order by id desc limit $ offset, $ pagesize", $ conn );
If ($ myrow = mysql_fetch_array ($ rs ))
{
$ I = 0;
?>
Do {$ I ++;?>
| }While ($ myrow = mysql_fetch_array ($ rs ));Echo"
";
}
Http://www.bkjia.com/PHPjc/444904.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444904.htmlTechArticlephp paging function php Tutorial paging function $ conn = mysql tutorial _ connect (localhost, root, 123456); $ pagesize = 4; // set the number of records displayed on each page. mysql_select_db (ly, $ conn); $ rs = mysql_query (...