怎么把查询和分页一起实现
<br />$page=isset($_GET['page'])?$_GET['page']:1; <br />$pagesize=20; <br />$sql="SELECT count(*) from khxx";<br />$res=mysql_query($sql);<br />$maxrows=mysql_result($res,0,0);<br />$maxpages=ceil($maxrows/$pagesize);<br />if($page>$maxpages){<br /> $page=$maxpages;}<br />if($page<1){<br /> $page=1;}<br />$limit=" limit ".(($page-1)*$pagesize).",{$pagesize}";<br /><br />if (!empty($_GET[keys])) {<br /> $keys=$_GET['keys'];<br /> $ww="`dates` like '%".$keys."%' or `area` like '%".$keys."%' ;<br /> $wh="where {$ww}";<br /> }<br />
<br /> <form action="khall.php" method="get"><br /> <input class="inp" type="text" name="keys"/ ><br /> <input class="sub" type="submit" value="查询"/><br /> </form><br /> </tr><br /> <tr><br /> <?php echo "当前{$page}/{$maxpages}页 共计{$maxrows}条";<br /> echo "<a href='khall.php?page=1'>首页</a>";<br /> echo "<a href='khall.php?page=".($page-1)."'>上一页</a>";<br /> echo "<a href='khall.php?page=".($page+1)."'>下一页</a>";<br /> echo "<a href='khall.php?page={$maxpages}'>末页</a>";<br /> ?><br /> </tr><br />
<?php<br /> <br /> $sql="SELECT * FROM `khxx` {$wh} order by id desc {$limit}";<br /> $query=mysql_query($sql);<br /> while ($rs=mysql_fetch_array($query)){<br /> ?><br /><br />
<br /><?php<br />$page=isset($_GET['page'])?$_GET['page']:1; <br />$pagesize=20; <br /><br />if (!empty($_GET[keys])) {<br /> $keys=$_GET['keys'];<br /> $ww="`dates` like '%".$keys."%' or `area` like '%".$keys."%' ";<br /> $wh="where {$ww}";<br />}else{<br /> $wh = ""<br />}<br /><br />$sql="SELECT count(*) from khxx ".$wh; // 计算总数时加入搜索条件 <br />$res=mysql_query($sql);<br />$maxrows=mysql_result($res,0,0);<br />$maxpages=ceil($maxrows/$pagesize);<br />if($page>$maxpages){<br /> $page=$maxpages;}<br />if($page<1){<br /> $page=1;}<br />$limit=" limit ".(($page-1)*$pagesize).",{$pagesize}";<br /><br />// 查询当前页记录 <br />$sql="SELECT * FROM `khxx` {$wh} order by id desc {$limit}";<br />$query=mysql_query($sql);<br />while ($rs=mysql_fetch_array($query)){<br /><br />?><br />
echo "<a href='khall.php?keys=$_GET['keys']&page=".($page-1)."'>上一页</a>";
<br /><?php<br />$page=isset($_GET['page'])?$_GET['page']:1; <br />$pagesize=20; <br /><br />if (!empty($_GET[keys])) {<br /> $keys=$_GET['keys'];<br /> $ww="`dates` like '%".$keys."%' or `area` like '%".$keys."%' ";<br /> $wh="where {$ww}";<br />}else{<br /> $wh = ""<br />}<br /><br />$sql="SELECT count(*) from khxx ".$wh; // 计算总数时加入搜索条件 <br />$res=mysql_query($sql);<br />$maxrows=mysql_result($res,0,0);<br />$maxpages=ceil($maxrows/$pagesize);<br />if($page>$maxpages){<br /> $page=$maxpages;}<br />if($page<1){<br /> $page=1;}<br />$limit=" limit ".(($page-1)*$pagesize).",{$pagesize}";<br /><br />// 查询当前页记录 <br />$sql="SELECT * FROM `khxx` {$wh} order by id desc {$limit}";<br />$query=mysql_query($sql);<br />while ($rs=mysql_fetch_array($query)){<br /><br />?><br />
效果和我写的差不多
我写的有个问题就是 点下一页后 当前的查询状态就消失了 想问下 怎么写才可以把查询加入到分页