• 有条件的,分页查询


    <body>
    <br />
    <!--查询表格-->
    <?php
    $name="";
    $tj="";   //分页条件
    if(!empty($_GET["name"]))   //多条件查询
    {
        $name = $_GET["name"];
        $tj = " where table_name like '%{$name}%'";
    }
    ?>
    
    <form>
        关键字:
        <input  type="text" name="name" value="<?php echo $name;   ?>" />
        <input  type="submit" value="提交"/>
    </form>
    
    <!--表格部分-->
    <br />
    <table border="1" cellpadding="0" cellspacing="0" width="100%">
    <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
    <td>5</td>
    <td>6</td>
    <td>7</td>
    </tr>
    
    <?php
    
    include("./DBDA.class.php");
    include("./page.class.php");
    
    $db = new DBDA();//因自定义housedb数据库,重新定义数据库
    $ss="mysql";
    
    $sqlall = "select count(*) from innodb_index_stats ".$tj;//有条件的SQL语句
    $result = $db->query($sqlall,0,$ss);
    $total = $result[0][0];
    $page = new Page($total,5);  
    
    $sqll = "select * from innodb_index_stats ".$tj.$page->limit;//有条件的分页查询
    $attr = $db->query($sqll,0,$ss);
    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>
        <td>$v[6]</td>
        </tr>";    
    }
    ?>
    
    </table>
    <br />
    <div style="background-color:#0FF" align="center"><?php  echo $page->fpage();     ?></div>
    
    </body>
    </html>

  • 相关阅读:
    257. Binary Tree Paths
    324. Wiggle Sort II
    315. Count of Smaller Numbers After Self
    350. Intersection of Two Arrays II
    295. Find Median from Data Stream
    289. Game of Life
    287. Find the Duplicate Number
    279. Perfect Squares
    384. Shuffle an Array
    E
  • 原文地址:https://www.cnblogs.com/wanlibingfeng/p/5485204.html
Copyright © 2020-2023  润新知