<?
if($action == 'search')
{
empty($baht_balx) && exit("请输入查询条件");
$sqlba="select * from $baht_table where (1=1)";
if($baht_balx) 
{
$sqlba=$sqlba." and baht_balx like '%$baht_balx%' ";
}
$query=mysql_query($sqlba);
$n=0;
$row=mysql_fetch_array($query);
$count=mysql_num_rows($query);
if(empty($offset))
{
$offset=0;
}
?><table width="57" height="23" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#333333">
  <tr class="style1">
    <td width="55" bgcolor="#FFFFFF"><div align="center" class="text">序号</div></td>
  </tr><?
$query=mysql_query($sqlba." order by baht_id desc limit $offset,$list_num") or die ("fail");
while($row=mysql_fetch_array($query))
{
if(($n%2)!='0')
{
echo "<tr bgcolor=#FFFFff>";}
else
{
echo "<tr bgcolor=#E4E4E4>";
}
echo"<td height='15' class='text'> <div align='center'>".$row['baht_id']."</div></td>
</tr> ";
$n++;
}
?>
</table><?
$pages=ceil($count/$list_num);
echo "<table width=770 border=0 cellspacing=0 cellpadding=0 align=center class='text'>
<tbody>
<tr>
<td width='159'><font color='#ff0000'>目前共有".$count." 条记录</font> </td>
<td width='205'>".$pages."页</td>";
if($offset)
{
$preoffset=$offset-$list_num;
print "<td width='132'><a href=\"$PHP_SELF?offset=$preoffset\">上一页</a></td>";}
else
{
echo "<td width='132'>上一页</td>";
}
$newoffset=$offset+$list_num;
if(($pages!=0)&&(($newoffset/$list_num)!=$pages))
{
print("<td width='158'><a href=\"$PHP_SELF?offset=$newoffset\">下一页</a></td>");
}
else

echo "<td width='158'>下一页</td>";
}
$pageno=($offset/$list_num)+1;
echo "<td width='112' class=text>第<input class=text type='text' size='4'value=".$pageno." readonly>
页</td>
<td width='4'>&nbsp;</td></tr>
</table>";
}
else
{
?><table width="266" border="0" cellspacing="1" cellpadding="0" class="text" bgcolor="#000000" align="center">
<!--DWLayoutTable-->
<form method="post" action="search.php">
<tr bgcolor="#E4E4E4">
  <td width="74" class="text"><P align=center>类型</P></td>
  <td width="189" height="30"><div align="center">
    <input name="baht_balx" type="text" id="baht_balx">
  </div></td>
</tr>
<tr bgcolor="#FFFFFF">
  <td height="30" colspan="4" class="text"><div align="center">
        <input type="hidden" name="action" value="search" >
        <input type="submit" value="查 询" class="text">
  </div></td>
  </tr>
</form>
</table>
<?}?>(附关键代码)

解决方案 »

  1.   

    分页参数传递问题
    参考改动方案:
    1.
    =======
    加一句
    if($action == 'search')
    {
     $baht_balx = $_REQUEST['baht_balx'];
    ..
    ..2.
    ========================
    改链接,将参数传递到下一页
    if($offset)
    {
    $preoffset=$offset-$list_num;
            print "<td width='132'><a href=\"$PHP_SELF?offset=$preoffset&action=search&baht_balx=$baht_balx\">上一页</a></td>";
    }
    ...
    ...
    ...
    if(($pages!=0)&&(($newoffset/$list_num)!=$pages))
    {
    print("<td width='158'><a href=\"$PHP_SELF?offset=$newoffset&action=search&baht_balx=$baht_balx\">下一页</a></td>");
    }
    结合自己情况改吧。