新手求助,PHP查询后,点下一页变成全部结果的下一页了,求帮我修改好!
<?phpinclude_once('conn.php');//判断检索值if($_POST['kewords']){$search.="andGoodsNOlike'%...
<?php
include_once('conn.php');
//判断检索值
if($_POST['kewords']){
$search .= " and GoodsNO like '%$_POST[kewords]%' or GoodsName like '%$_POST[kewords]%'";
}
$query = "select * from V_WareHouseStockByGoodsID where 1=1 and bBlockUp=0 $search";
//执行查询语句
$rresult = mssql_query($query) or die("无法执行SQL:$query");
//$page变量标示当前显示的页
$gPageSize= 10; //每页显示的记录数
if(!isset($page)) $page=1;
if($page==0) $page=1;
//得到当前查询到的纪录数
if(($nNumRows= mssql_num_rows($rresult))<=0)
{
echo "<p align=center>没有纪录";
exit;
};
//得到最大页码数MaxPage
$MaxPage = (int)ceil($nNumRows/$gPageSize);
if((int)$page > $MaxPage)
$page=$maxPage;
?>
<body>
<div class="row-fluid">
<form class="well form-search" action="" method="post">
<input type="text" class="input-medium search-query" name="kewords" value="请输入编号"/>
<input class="btn" type="submit" value="搜 索"/>
<a href="kccx.php" class="btn btn-primary pull-right"><i class="icon-pencil icon-white"></i>全部</a>
</form>
<p><font size="6" face="黑体">库存查询</font></p>
<table align="center" width="100%" border=0> <tr><td> <? echo "<font size=2>第
$page 页,共 $MaxPage 页</font>";?> </td><td></td></tr></table>
<table align="center" width="100%" border="1" cellspacing="0" cellpadding="4"
<table class="table table-striped table-bordered table-condensed"><thead>
<?
//显示表格头
for($iCnt = 0; $iCnt < mssql_num_fields($rresult); $iCnt++)
{
echo "<td>".mssql_field_name($rresult,$iCnt)."</td>" ;
}
?>
<td>操作</td></tr>
<?
//根据偏移量($page - 1)*$gPageSize,运用mssql_data_seek函数得到要显示的页面
if( mssql_data_seek($rresult,($page-1)*$gPageSize) )
{
$i=0;
//循环显示当前纪录集
for($i;$i<$gPageSize;$i++)
{
echo "<tr style=\"font-size:12px\">";
//得到当前纪录,填充到数组$arr;
$arr= mssql_fetch_row($rresult);
if($arr)
{
//循环显示当前纪录的所有字段值
for($nOffSet = 0;$nOffSet < count($arr);$nOffSet++)
{
echo "<td>".$arr[$nOffSet]."</td>";
}
echo "<td><a href=\"edit_adressList.php?id=$arr[0]\" class=\"btn\"><i class=\"icon-pencil\"></i>详情</a></tr>";
}
}
}
?>
</table>
<hr size=1 width=100%>
<div align=center style="font-size:15px">
<?
//首页和上一页的链接
if( $nNumRows>1 && $page>1)
{
$prevPage=$page-1;
echo " <a href=".$PHP_SELF."?page=1>首页</a> ";
echo " <a href=".$PHP_SELF."?page=".$prevPage." >上一页</a> ";
}
//下一页和末页的链接
if( $page>=1 && $page<$MaxPage)
{
$nextPage= $page+1;
echo " <a href=".$PHP_SELF."?page=".$nextPage." >下一页</a> ";
echo " <a href=".$PHP_SELF."?page=".$MaxPage." >末页</a> ";
}
?>
<footer>
<p>© Company 2015</p>
</body>
</html> 展开
include_once('conn.php');
//判断检索值
if($_POST['kewords']){
$search .= " and GoodsNO like '%$_POST[kewords]%' or GoodsName like '%$_POST[kewords]%'";
}
$query = "select * from V_WareHouseStockByGoodsID where 1=1 and bBlockUp=0 $search";
//执行查询语句
$rresult = mssql_query($query) or die("无法执行SQL:$query");
//$page变量标示当前显示的页
$gPageSize= 10; //每页显示的记录数
if(!isset($page)) $page=1;
if($page==0) $page=1;
//得到当前查询到的纪录数
if(($nNumRows= mssql_num_rows($rresult))<=0)
{
echo "<p align=center>没有纪录";
exit;
};
//得到最大页码数MaxPage
$MaxPage = (int)ceil($nNumRows/$gPageSize);
if((int)$page > $MaxPage)
$page=$maxPage;
?>
<body>
<div class="row-fluid">
<form class="well form-search" action="" method="post">
<input type="text" class="input-medium search-query" name="kewords" value="请输入编号"/>
<input class="btn" type="submit" value="搜 索"/>
<a href="kccx.php" class="btn btn-primary pull-right"><i class="icon-pencil icon-white"></i>全部</a>
</form>
<p><font size="6" face="黑体">库存查询</font></p>
<table align="center" width="100%" border=0> <tr><td> <? echo "<font size=2>第
$page 页,共 $MaxPage 页</font>";?> </td><td></td></tr></table>
<table align="center" width="100%" border="1" cellspacing="0" cellpadding="4"
<table class="table table-striped table-bordered table-condensed"><thead>
<?
//显示表格头
for($iCnt = 0; $iCnt < mssql_num_fields($rresult); $iCnt++)
{
echo "<td>".mssql_field_name($rresult,$iCnt)."</td>" ;
}
?>
<td>操作</td></tr>
<?
//根据偏移量($page - 1)*$gPageSize,运用mssql_data_seek函数得到要显示的页面
if( mssql_data_seek($rresult,($page-1)*$gPageSize) )
{
$i=0;
//循环显示当前纪录集
for($i;$i<$gPageSize;$i++)
{
echo "<tr style=\"font-size:12px\">";
//得到当前纪录,填充到数组$arr;
$arr= mssql_fetch_row($rresult);
if($arr)
{
//循环显示当前纪录的所有字段值
for($nOffSet = 0;$nOffSet < count($arr);$nOffSet++)
{
echo "<td>".$arr[$nOffSet]."</td>";
}
echo "<td><a href=\"edit_adressList.php?id=$arr[0]\" class=\"btn\"><i class=\"icon-pencil\"></i>详情</a></tr>";
}
}
}
?>
</table>
<hr size=1 width=100%>
<div align=center style="font-size:15px">
<?
//首页和上一页的链接
if( $nNumRows>1 && $page>1)
{
$prevPage=$page-1;
echo " <a href=".$PHP_SELF."?page=1>首页</a> ";
echo " <a href=".$PHP_SELF."?page=".$prevPage." >上一页</a> ";
}
//下一页和末页的链接
if( $page>=1 && $page<$MaxPage)
{
$nextPage= $page+1;
echo " <a href=".$PHP_SELF."?page=".$nextPage." >下一页</a> ";
echo " <a href=".$PHP_SELF."?page=".$MaxPage." >末页</a> ";
}
?>
<footer>
<p>© Company 2015</p>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询