标签:
<?php include "page.class.php"; include "db.class.php"; $db = new DB(); $name = ""; $tj = ""; if(!empty($_POST["mc"])) //判断查询文本框是否有值 { $name = $_POST["mc"]; $tj = "n={$name}"; //***分页条件 } if(!empty($_GET["n"])) //根据post传值判断 { $name = $_GET["n"]; $tj = "name={$name}"; } $w = " where AreaName like ‘%{$name}%‘ "; //条件查询 ?><br /> <form action="fenye.php" method="post"> <!--建立查询按钮--> <div> 请输入名称: <input type="text" name="mc" value="<?php echo $name ?>" /> <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 $sql1 = "select count(*) from chinastates ".$w; //数据总量 $attr = $db->Query($sql1); $total = $attr[0][0]; $page = new Page($total,10,$tj,true); //1,数据总量 2,每页的数据量 3,分页条件 4,true显示首页、false显示末页 $sql2 = "select * from chinastates ".$w.$page->limit; //条件分页查询 $r = $db->Query($sql2); foreach ($r as $v) { echo "<tr><td>{$v[0]}</td><td>{$v[1]}</td><td>{$v[2]}</td></tr>"; } ?> </table><br /> <?php echo $page->fpage(); //分页查询菜单 ?>
标签:
原文地址:http://www.cnblogs.com/1116zsc/p/5485440.html