• php分页查询


    分页查询页面

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    
    <body>
    <?php
    include("DBDA.class.php");
    $db = new DBDA();
    include "page.class.php";
    
    $tj1 = " 1=1 ";//默认值的写入
    $area = "";
    if(!empty($_GET["area"]))//由于page.class.php类文件,用的是get方法
    {
        $area = $_GET["area"];
        $tj1 = " areaname like '%{$area}%' ";
    }
    
    ?>
    <h1>中国省市区</h1>
    <form action="1.php" method="get">
    <div>地区名称:<input type="text" name="area" value="<?php echo $area; ?>" /> 
    <input type="submit" value="查询" /></div>
    </form>
    <br />
    <table width="100%" border="1" cellpadding="0" cellspacing="0">
        <tr>
            <td>地区代号</td>
            <td>地区名称</td>
            <td>父级代号</td>
        </tr>
        
        <?php
        
        
        $sall = "select count(*) from chinastates where {$tj1}";//加条件
        $aall = $db->Query($sall);
        $page = new Page($aall[0][0],20);//如用post此处可以new Page($aall[0][0],20,"area={$area}")第三个参数可以像get方法的在地址栏里显示。
                         //但是由于page.class.php类文件是get方法的,如果用post显示有问题。
    $sql = "select * from chinastates where {$tj1} ".$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> </html>
  • 相关阅读:
    Flink 窗口API & 窗口分配器
    selenium 远程浏览器selenoid服务搭建
    钉钉设置极速打卡
    iphone不设置密码钉钉自动打卡
    C++对象间通信组件,让C++对象“无障碍交流”
    Ubuntu20 安装最新cmake,以及NO_PUBKEY问题踩坑
    蜻蜓低代码安全工具平台开发之路
    后缀数组
    后缀数组SA 回文自动机PAM
    git 系列
  • 原文地址:https://www.cnblogs.com/gaobint/p/6478133.html
Copyright © 2020-2023  润新知