Paging details from this page (PHP + mysql ). All the code I sent is original and applied to multiple projects. I often use php + mysql paging code to copy the code as follows :? Php $ perpagenum10; defines how many pieces of code are displayed on each page, all of which are original and applied to multiple projects. you often use php + mysql paging code.
The code is as follows:
$ Perpagenum = 10; // defines the number of entries displayed on each page.
$ Total = mysql_fetch_array (mysql_query ("select count (*) from a"); // query the total number of data records in the database
$ Total = $ total [0]; //
$ Totalpage = ceil ($ Total/$ perpagenum); // go to the house and get the integer
If (! Isset ($ _ GET ['Page']) |! Intval ($ _ GET ['Page']) | $ _ GET ['Page']> $ Totalpage) // Four possible page states
{
$ Page = 1;
}
Else
{
$ Page = $ _ GET ['Page']; // if the preceding conditions are not met, the page value is $ _ GET ['Page']
}
$ Startnum = ($ page-1) * $ perpagenum; // number of start entries
$ SQL = "select * from a order by id limit $ startnum, $ perpagenum"; // query the number of required entries
Echo $ SQL ."
";
$ Rs = mysql_query ($ SQL );
$ Contents = mysql_fetch_array ($ rs );
If ($ total) if $ total is not empty, execute the following statement:
{
Do
{
$ Id = $ contents ['id'];
$ Name = $ contents ['name'];
?>
}
While ($ contents = mysql_fetch_array ($ rs); // do... while
$ Per = $ page-1; // Previous page
$ Next = $ page + 1; // next page
Echo" A Total of ". $ Total." records, each page ". $ perpagenum.", Total ". $ Totalpage." page ";
If ($ page! = 1)
{
Echo "homepage ";
Echo "previous page ";
}
If ($ page! = $ Totalpage)
{
Echo "next page ";
Echo "last page ";
}
}
Else outputs No message if $ total is null
{
Echo" No message ";
}
?>
Ghost. I often use php + mysql paging code as follows :? Php $ perpagenum = 10; // defines the number of entries displayed on each page...