关于表单提交查询问题
第一次查询能成功,假如我要对查询结构分页,我如何保存率选值呢?
不知道各位对我提的问题明白否?请高手指点!
<?
$cwhname=$_POST['cwhname'];
$currentstock=$_POST['currentstock'];
if($currentstock and !$cwhname){
$querygb="select * from $dbtable where currentstock>='".$_POST['currentstock']."'";
}
elseif($cwhname and !$currentstock){
$querygb="select * from $dbtable where cwhname='".$_POST['cwhname']."'";
}
elseif($currentstock and $cwhname){
$querygb="select * from $dbtable where cwhname='".$_POST['cwhname']."'and currentstock>='".$_POST['currentstock']."'";
}
else
{
echo '请选择查询条件';
exit();
}
//$querygb="select * from $dbtable where cwhname='".$_POST['cwhname']."'and currentstock>='".$_POST['currentstock']."'";
$resgb = mssql_query($querygb);
$count=mssql_num_rows($resgb);
if(!isset($_GET['listnum']))$listnum=20;
else $listnum=$_GET['listnum'];
$pagecount=ceil($count/$listnum);
if(!($row[0] = mssql_fetch_row($resgb))) die("没有符合条件的记录!");
for($i=1;$i<$count;$i++)
{$row[$i] = mssql_fetch_row($resgb);
}
if(!isset($_GET['page']))
{ $page=1;
}
else
{ $page=$_GET['page'];
}
$prepage=$page-1;
$nextpage=$page+1;
for($i=($page-1)*$listnum;$i<$page*$listnum;$i++)
{if($page==$pagecount)
{
if(!isset($row[$i])) break;
}
?>
<tr bgcolor="#F1FFE1" onmouseover=this.style.backgroundColor='ffcccc' onmouseout=this.style.backgroundColor='F1FFE1'>
<td height="18"> <?echo $row[$i][2];?> </td>
<td> <?echo $row[$i][8];?></td>
<td align="center"> <?echo $row[$i][6];?> </td>
<td align="center"> <?echo $row[$i][5];?> </td>
<td> <?echo $row[$i][9];?></td>
<td> <?echo $row[$i][11];?></td>
</tr>
<?}?>
<tr bgcolor="#F1FFE1" align="center">
<td colspan="6" height="30">
<?
echo "现有记录".$count."条 "."每页显示".$listnum."条 ";
echo "这是第".$page."页 ";
if($page>1)
{ echo "<a href='check.php?page=1'><font color=#000000>首页</font></a> ";
echo "<a href='check.php?page=$prepage'><font color=#000000>上一页</font></a> ";
}
if($pagecount>1)
{ if($page!=$pagecount)
{ echo "<a href='check.php?page=$nextpage'><font color=#000000>下一页</font></a> ";
echo "<a href='check.php?page=$pagecount'><font color=#000000>尾页</font></a> ";
}
}
?>