php中的实用分页类

<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>地区代号</td>
<td>地区名称</td>
<td>父级代号</td>
</tr>

<?php
include("LZY.class.php");
$db = new LZY();
include("page.class.php");

//查总条数
$sz = "select count(*) from chinastates";
$az = $db->Query($sz);

//1.造对象
$page = new Page($az[0][0],10);

//2.将分页类的limit变量拼接在SQL语句后面
$sql = "select * from chinastates ".$page->limit;

$arr = $db->Query($sql);

foreach($arr as $v)
{
echo "<tr>
<td>{$v[0]}</td>
<td>{$v[1]}</td>
<td>{$v[2]}</td>
</tr>";
}
?>

</table>

<?php

//3.输出分页信息
echo $page->fpage();

?>



</body>


原文地址:https://www.cnblogs.com/li1056822533/p/6445613.html