查询当前页能查询,但是点下一页和上一页都没反应,我问别人说是下一页参数没传递,单具体修改不太会 请教各位大虾帮忙该如何修改传递参数到下一页上哈谢谢了??(本例子是查询2个时间的结果分页)
/////search.php  (查询页面)
<form name="form1" method="post" action="check_search_affiche.php">
<tr align="center">
  <div align="center"><font size="10">内科日报查询&nbsp;</font></div>
</tr>
    <div align="center">日期查询
      <input name="txt_keyword2" type="text" id="a"size="20" />    //时间1
      <input name="txt_keyword3" type="text" id="b" size="20" />   //时间2
      <input type="submit" name="Submit" value="搜索" onclick="return check(form)">
    </div>
</form>
/////check_search_affiche.php(查询结果)<?
$conn=mysql_connect("localhost","root","root")or die("数据库服务器链接错误".mysql_error());
mysql_select_db("db_database19",$conn)or die("数据库访问错误".mysql_error()); $keyword2=$_POST[txt_keyword2];
$keyword3=$_POST[txt_keyword3];
$sql="SELECT * FROM `neike` WHERE createtime >='$keyword2 00:00:00' and createtime <='$keyword3 23:59:59' order by createtime desc";
mysql_query("set names utf8");
$rec=mysql_query($sql,$conn);$total=mysql_num_rows($rec);
$PageSize=6;
$TotalRows=$total;//总共有多少记录
$TotalPages=ceil($TotalRows/$PageSize);//总共有多少页
$Rowstring=" "."共有 ".$TotalPages." 页";if(isset($_GET["showPage"]))
{
$showPage=intval($_GET["showPage"]);
}
else
{
$showPage=1;
}
$CurrentLocation.=$_SERVER["PHP_SELF"];
$sql0="SELECT * FROM `neike` WHERE createtime >='$keyword2 00:00:00' and createtime <='$keyword3 23:59:59' order by createtime desc"." limit ".($showPage-1)*$PageSize.",".$PageSize;
//echo $sql;
$result=mysql_query($sql0,$conn);
$tmpi=0;
?><form name="form1" method="post" action="check_search_affiche.php">
<tr align="center">
  <div align="center"><font size="10">内科日报查询&nbsp;</font></div>
</tr>
    <div align="center">日期查询
      <input name="txt_keyword2" type="text" id="a"size="20" />
      <input name="txt_keyword3" type="text" id="b" size="20" />
      <input type="submit" name="Submit" value="搜索" onclick="return check(form)">
    </div>
</form>
<script language="javascript">
function check(form){
if(form.a.value==""){
alert("请输入查询关键字!");form.a.focus();return false;
}
form.submit();
}
</script>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="700" height="14" background="images/client/news_x.jpg" style="border-bottom:#e5e5e5 1px solid;border-left:#e5e5e5 1px solid;border-right:#e5e5e5 1px solid;border-top:#c75701 2px solid; color:#006633"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr align="center">
        <td width="10%" class="enfont">主治医师</td>
        <td width="1"></td>
        <td width="13%" class="enfont">其他医师</td>
        <td width="1"></td>
        <td width="13%" class="enfont">初诊人数</td>
        <td width="1"></td>
        <td width="13%" class="enfont">复诊人数</td>
        <td width="1"></td>
        <td width="13%" class="enfont">体检人数</td>
        <td width="1"></td>
        <td width="15%" class="enfont">报表人签字</td>
        <td width="1"></td>
        <td width="25%" class="enfont">时间</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="300" valign="top" style="border-left:#e5e5e5 1px solid;border-right:#e5e5e5 1px solid;"><table width="100%" border="0" cellpadding="0">
      <? while($row=mysql_fetch_array($result)){ ?>
      <tr align="center" class="font">
        <td width="10%" height="14"  style="border-bottom:#efefef 1px solid"><font size="2"><?=$row['zhuzhi']?></font></td>
        <td width="1" style="border-bottom:#efefef 1px solid"></td>
        <td width="13%" align="center" style="border-bottom:#efefef 1px solid"><a href="news_detail.php?id=<?=$row['qita']?>" target="_blank">
          <?=$row['qita']?>
        </a></td>
        <td width="1" style="border-bottom:#efefef 1px solid"></td>
        <td width="13%" style="border-bottom:#efefef 1px solid"><?=$row['chuzhen']?></td>
        <td width="1" style="border-bottom:#efefef 1px solid"></td>
        <td width="13%" style="border-bottom:#efefef 1px solid"><?=$row['fuzhen']?></td>
        <td width="13%" style="border-bottom:#efefef 1px solid"><?=$row['tijian']?></td>
        <td width="15%" style="border-bottom:#efefef 1px solid"><?=$row['name']?></td>
        <td width="30%" style="border-bottom:#efefef 1px solid"><font size="2"><?=$row['createtime']?></font></td>
      </tr>
      <?
    $tmpi++;
   }
  ?>
    </table></td>
  </tr>
  <tr>
    <td height="50" style="border-top:#c75701 2px solid;"><table cellspacing="0" cellpadding="0" width='100%' align="center">
      <tr>
        <td align="right" class="page_break"><?php if($showPage > 1){?>
              <a href="<?php echo $CurrentLocation;?>?showPage=<?php echo $showPage-1;?>">上一页</a>
              <?php }
if($TotalPages==1){}
else if($showPage==1&&$TotalPages>1){
echo "1";
for($p=2;$p<=5&&$p<=$TotalPages;$p++){?>
              <a href="<?php echo $CurrentLocation;?>?showPage=<?php echo $p;?>"><?php echo $p;?></a>
              <?php }}
else if($showPage<=5){
for($p=1;$p<=4+$showPage&&$p<=$TotalPages;$p++){
if($p==$showPage){
echo $p;?>
              <?php }else{?>
              <a href="<?php echo $CurrentLocation;?>?showPage=<?php echo $p;?>"><?php echo $p;?></a>
              <?php }}}else if($showPage>5) {
for($p=$showPage-5;$p<=$showPage+4&&$p<=$TotalPages;$p++){
if($p==$showPage){
echo $p;?>
              <?php }else{?>
              <a href="<?php echo $CurrentLocation;?>?showPage=<?php echo $p;?>"><?php echo $p;?></a>
              <?php }}}?>
              <?php if(($showPage < $TotalPages)&&($TotalPages<>1)){?>
              <a href="<?php echo $CurrentLocation;?>?showPage=<?php echo $showPage+1;?>">下一页</a>
              <?php }?>
              <?php
echo $Rowstring;  
?>
        </td>
      </tr>
    </table></td>
  </tr>
</table>

解决方案 »

  1.   

    打印下sql语句  在命令行运行下
      

  2.   

    你第一次搜索的时候,取了时间关键词,但是分页链接是get方式,也不带参数,当然会有误
    给个参考方案吧所有的分页链接,除了showPage,都加上txt_keyword2=……&txt_keyword3=……//省略号是具体的值
    页面取值改成$_REQUEST,不要用$_POST