I send the code all for my original, and applied in a number of projects. I often use php+mysql pagination code
Copy CodeThe code is as follows:
$perpagenum = 10;//definition shows several pages per page
$total = Mysql_fetch_array (mysql_query ("SELECT count (*) from a"));//Query the database for the total number of data
$Total = $total [0]; //
$Totalpage = Ceil ($Total/$perpagenum);//upper loft, rounding
if (!isset ($_get[' page ') | |! Intval ($_get[' page ') | | $_get[' page ']> $Totalpage)//page possible four states
{
$page = 1;
}
Else
{
$page =$_get[' page '];//if the above four cases are not met, the value of page is $_get[' page '
}
$startnum = ($page-1) * $PERPAGENUM;//Start bar number
$sql = "SELECT * from a the order by ID limit $startnum, $perpagenum";//query out the required number of bars
echo $sql. "
";
$rs = mysql_query ($sql);
$contents = Mysql_fetch_array ($RS);
if ($total) Execute the following statement if $total is not empty
{
Do
{
$id = $contents [' id '];
$name = $contents [' name '];
?>
}
while ($contents = Mysql_fetch_array ($rs));//do....while
$per = $page -1;//Previous page
$next = $page + 1;//Next
echo " Total ". $Total." Records, per page ". $perpagenum." Bar, Total ". $Totalpage." Page ";
if ($page! = 1)
{
echo "Home";
echo "Prev";
}
if ($page! = $Totalpage)
{
echo "Next page";
echo "Last ";
}
}
Else output no message if $total is empty
{
echo " No message ";
}
?>
http://www.bkjia.com/PHPjc/318581.html www.bkjia.com true http://www.bkjia.com/PHPjc/318581.html techarticle I send the code all for my original, and applied in a number of projects. I often use the Php+mysql page code to copy code as follows:? PHP $perpagenum =10;//definition shows a few pages per page ...