调用上一篇的 “分页类” 显示数据库内容
<title>数据分页类</title>
</head>
<body>
<h1>分页显示</h1>
<table width="900px" border="1" cellpadding="0" cellspacing="0">
<tr align="center">
<td>代号</td>
<td>名称</td>
<td>父级代号</td>
</tr>
<?php
include("DBDA.class.php"); //调用数据查询方法类
include("page.class.php"); //调用数据分页类
$db=new DBDA();
$sqlall="select count(*) from chinastates";
$attrall=$db->Query($sqlall);
$total=$attrall[0][0];
$page=new Page($total,15); //需要参数 1.数据总条数
$sql="select * from chinastates ".$page->limit;
$attr=$db->Query($sql);
foreach($attr as $v)
{
echo "<tr align='center'>
<td>{$v[0]}</td>
<td>{$v[1]}</td>
<td>{$v[2]}</td>
</tr>";
}
?>
</table>
<?php
echo "<div>".$page->fpage()."</div>";
?>
</body>
</html>