Copy Code code as follows:
<?php
$perpagenum = 10;//defines a few per-page display
$total = Mysql_fetch_array (mysql_query ("SELECT count (*) from a");//How many data are there in the query database
$Total = $total [0]; //
$Totalpage = Ceil ($Total/$perpagenum);/upper house, 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 conditions are not met, the page value is $_get[' page ']
}
$startnum = ($page-1) * $perpagenum//number of start bars
$sql = "SELECT * FROM (a) Order by ID limit $startnum, $perpagenum"//query out required number of bars
echo $sql. "
";
$rs = mysql_query ($sql);
$contents = Mysql_fetch_array ($RS);
if ($total) executes the following statement if $total is not empty
{
Todo
{
$id = $contents [' id '];
$name = $contents [' name '];
?>
<table border= "0" align= "center" >
<tr>
<td>id:
<?php echo $id;? >
</td>
</tr>
<tr>
<td>name:
<?php echo $name;? >
</td>
</tr>
</table>
<?php
}
while ($contents = Mysql_fetch_array ($rs));//do....while
$per = $page -1;//Previous page
$next = $page + 1;//Next page
echo "<center> common". $Total. " Record, per page ". $perpagenum." , $Totalpage. " Page ";
if ($page!= 1)
{
echo "<a href= '". $_server[' php_self '. "' > Home </a> ";
echo "<a href= '". $_server[' php_self '. Page= '. $per. "' > Prev </a> ";
}
if ($page!= $Totalpage)
{
echo "<a href= '". $_server[' php_self '. Page= '. $next. "' > next page </a> ";
echo "<a href= '". $_server[' php_self '. Page= '. $Totalpage. "' > Last </a></center> ";
}
}
Else output no message if $total is empty
{
echo "<center>no message</center>";
}
?>