How to implement practical paging class through php

迷茫
Release: 2023-03-06 22:44:02
Original
1715 people have browsed it

Practical paging class in 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>
Copy after login

The above is the detailed content of How to implement practical paging class through php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template