• 分页查询:使用分页类查询 用get传值


    <body>
    <?php
    $cx = "";
    if(!empty($_GET["cx"]))                                          //判断get传过来的值非空,那么把传过来的值赋给变量$cx
    {
        $cx = $_GET["cx"];    
    }
    ?>
    <form action="fenyechaxun.php" method="get">
    关键字:<input type="text" name="cx" value="<?php echo $cx; ?>" /><input type="submit" value="查询" />  //把用户输入的关键字留在文本框'text'中
    <table width="100%" border="1" cellpadding="0" cellspacing="0">
    <tr>
        <td>areacode</td>
        <td>areaname</td>
        <td>parentareacode</td>
        <td>root</td>
        <td>zone</td>
        <td>nacigateurl</td>
    </tr>
    <?php
    include("../fzl/czy.class.php");
    $db = new czy();
    $tj = " 1=1 ";                                 //条件$tj=' 1=1 '时,点搜索是搜索全部;
    if(!empty($_GET["cx"] )&& $_GET["cx"] !="")                //如果get传过来的值 $_GET["cx"]非空且不是空的字符串是 把$tj 加在sql语句后边
    {
        $tj = " areaname like '%{$_GET['cx']}%' ";    
    }
    $stotal = " select count(*) from chinastates where {$tj} ";       //求数据库的总条数
    $arr = $db->strQuery($stotal);
    include("../fzl/page.class.php");
    $page = new Page($arr,20);
    $sql = " select * from chinastates where {$tj} ".$page->limit;     //分页分页
    $attr = $db->Query($sql);
    foreach($attr as $v)
    {
        echo "<tr>
                <td>{$v[0]}</td>
                <td>{$v[1]}</td>
                <td>{$v[2]}</td>
                <td>{$v[3]}</td>
                <td>{$v[4]}</td>
                <td>{$v[5]}</td>
              </tr>";    
    }
    ?>
    </table>
    </form>
    <?php
    echo $page->fpage();                             //分页分页
    ?>
    </body>
  • 相关阅读:
    分不清npm cnpm npx nvm ?
    gulp 中对于css文件的压缩合并出现的unable to minify JavaScript问题
    JS实现选项卡和JQ实现选项卡
    前端性能的优化
    JS中事件绑定的方式以及事件监听和事件的委托
    简易轮播图和无缝轮播图的实现
    ES6中对象的扩展以及新增方法
    javascript的基本介绍和发展
    this浅谈
    浅谈DOM的概念和作用
  • 原文地址:https://www.cnblogs.com/zxl89/p/6048260.html
Copyright © 2020-2023  润新知