zoukankan      html  css  js  c++  java
  • 分页查询:使用分页类查询 用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>
  • 相关阅读:
    [Codeforces 1290C]Prefix Enlightenment
    [JLOI 2015]战争调度
    [APIO 2010]特别行动队
    [CEOI 2004]锯木厂选址
    [USACO 08MAR]土地购买
    [HNOI 2017]大佬
    [NOI 2011]NOI 嘉年华
    [SHOI 2013]超级跳马
    [NOI 2005]瑰丽华尔兹
    [SCOI 2010]股票交易
  • 原文地址:https://www.cnblogs.com/zxl89/p/6048260.html
Copyright © 2011-2022 走看看