Home >Backend Development >PHP Tutorial >How to implement practical paging class through php

How to implement practical paging class through php

迷茫
迷茫Original
2017-03-26 10:54:191768browse

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>

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!

Statement:
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