分页

为么休息日过得总是累得跟狗似的…一整个上午都耗在医院吊水了,急不得燥不得各种吃不得,苦逼的我实在是无语了跟先生随便吃了点又赶场似的去给妈妈调换衣服,五一到现在因为身体的原因都没有回去看过妈妈了…然后又去取了给小妞儿爷爷订的枕头,然后回家做作业,一会还得回这边妈妈家,时间真的不够用的……

昨天老师讲了分页自己试着做了一下

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
    <td>代号</td>
    <td>名称</td>
    <td>父级代号</td>
</tr>
<?php
include("ChaXun.class.php");
include("page.class.php");
$db=new ChaXun();
$sqlall="select count(*) from chinastates";
$attrall=$db->Query($sqlall);
//var_dump($attrall);
$total=$attrall[0][0];
$fy=new Page($total,20);
$sql="select * from chinastates ".$fy->limit;
$attr=$db->Query($sql);
foreach ($attr as $v)
{
    echo"<tr>
        <td>{$v[0]}</td>
        <td>{$v[1]}</td>
        <td>{$v[2]}</td>
        </tr>";
}

?>
</table>
<?php
    echo $fy->fpage();
?>
</body>
</html>

原文地址:https://www.cnblogs.com/nannan-0305/p/5483312.html