首页 > Web开发 > 详细

php分页查询

时间:2017-02-28 13:46:51      阅读:151      评论:0      收藏:0      [点我收藏+]

分页查询页面

<!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>

 

php分页查询

原文:http://www.cnblogs.com/gaobint/p/6478133.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!