zoukankan      html  css  js  c++  java
  • php分页查询的简单实现代码

    <body>
    <h1>分页查询</h1>
    <?php
    include("DADB.class.php");
    $db=new DADB();
    $tj= " 1=1 ";
    $area="";
    if(!empty($_GET["area"]))
    {
    $area=$_GET["area"];
    $tj=" areaname like '%{$area}%'";
    }
    ?>
    <form action="fenyechaxun.php" method="get" >
    //这里用的是get 来获取
    <div>地区名称:<input type="text" name="area" value="<?php echo $area; ?>"/>
    //这里如果没有传入value值 如果查询内容的数量比较多,
    那么在第二页的时候将与需要查询的内容不符
    <input type="submit" value="查询"/></div>
    </form>
    <table border="1" cellpadding="0" cellspacing="0" width="100%">
    <tr>
    <td>地区代号</td>
    <td>地区名称</td>
    <td>父级代号</td>
    </tr>
    <?php
    include("page.class.php");
    $sqg="select count(*) from chinastates WHERE {$tj}";
    //因为是需要查询,所以 select语句都要有条件
    $arg=$db->Query($sqg);
    $page=new page($arg[0][0],20);
    //如果前面用的是post 那么这里 可以改为new page(, , "areaname='{$area}'" )
    $sql="select * from chinastates where {$tj}" .$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>
    <div> <?php
    echo $page->fpage();
    ?></div>
    </body>

  • 相关阅读:
    Python列表、元组、字典、集合的方法
    Python字符串方法总结
    进程、线程、协和的对比
    案例:图片下载器
    使用gevent实现多任务
    使用greenle完成多任务
    使用yield完成多任务
    生成器总结
    生成器send函数
    生成器yield关键字
  • 原文地址:https://www.cnblogs.com/2881064178dinfeng/p/7133389.html
Copyright © 2011-2022 走看看