第一页是根据条件查询出来的点下一页就变成无条件查询时的数据了
(新手没多少分)

解决方案 »

  1.   

    往下一页的链接上加查询条件,或者session/cookie 保存查询条件。建议使用后者,考虑直接刷新页面的情况。
      

  2.   

    --------tpl.pages.php-----
    <?php
    $Total = $total[0];//查询数据库中一共有多少条数据 
    if($_GET['page']=="")

    $page=1; 

    else 

    $page=$_GET['page']; 

    //获得当前页 
    $startnum = ($page-1)*$perpagenum;//每页的其实位置 
    if($page>1)
    $per=$page-1;
    else
    $per=1;
    if($Total%$perpagenum==0)
    $Totalpage=$Total/$perpagenum;
    else
    $Totalpage=(integer)($Total/$perpagenum)+1;
    $next=$page+1;
    if($next>=$Totalpage)
     $next=$Totalpage;
     ?>
     <?php
    $xian="<a href='".$_SERVER['PHP_SELF']."'>首页</a>"."<a href='".$_SERVER['PHP_SELF'].'?page='.$per."'> 上一页</a>". 
    "<a href='".$_SERVER['PHP_SELF'].'?page='.$next." '>下一页</a>". 
    "<a href='".$_SERVER['PHP_SELF'].'?page='.$Totalpage." '> 尾页</a>".
    " 第".$page."/".$Totalpage."页 ".
    " 共".$Total."条信息</center>";
    ?>---------tpl.renyuanchaxun.php------<?php
    session_start();
    $name1=$_SESSION['name'];
    $bumen1=$_SESSION['bumen'];
    ?>
    <form id="form1" name="form1" method="post" action="tpl.rizhichaxun.php">
    <SCRIPT language="javascript" src="js/calendar.js" type="text/javascript"></SCRIPT>
      <table width="756" border="1">
        <tr>
          <th width="96" align="right" scope="col">登录名:</th>
          <th width="168" scope="col"><input type="text" name="name" /></th>  
          <th width="79" scope="col">部门:</th>
          <th width="71" scope="col"><select name="select">
              <option value="办公室">办公室</option>
              <option value="技术部" >技术部</option>
              <option value="业务部">业务部</option>
              <option value="其他">其他</option>
              <option value="" selected="selected"> </option>
          </select></th>
          <th width="86" align="right" scope="col">时间:</th>
          <input type="submit" name="Submit" value="查询" /></th>
        </tr>
      </table>
      <table width="100%" border="0" cellpadding="5" cellspacing="1">
        <tr style="color:#FFF;">
          <td bgcolor="#11324B" width="10%"><div align="center">登录名</div></td>
          <td bgcolor="#11324B" width="9%"><div align="center">部门</div></td>
          <td width="8%" bgcolor="#11324B"><div align="center">职务</div></td>
          <td width="16%" bgcolor="#11324B"><div align="center">添加时间</div></td>
          <td width="12%" bgcolor="#11324B"><div align="center">是否审核</div></td>
          <td width="16%" bgcolor="#11324B"><div align="center">审核时间</div></td>
          <td width="14%" bgcolor="#11324B"><div align="center">审核人</div></td>
          <td width="7%" bgcolor="#11324B"><div align="center">状态</div></td>
          <td width="8%" bgcolor="#11324B"><div align="center">详细信息</div></td>
          <td width="5%" bgcolor="#11324B"><div align="center">删除</div></td>
     </tr>
        <?php
    $name=$_POST["name"];
    $bumen=$_POST["select"];
    $shijian=$_POST["textfield"];
    $perpagenum =10;//定义每页显示几条 
    $myconn=mysql_connect("localhost","root","123456");
    mysql_select_db("rizhi",$myconn);
    mysql_query("set names 'gbk'");$strsql="select count(*) from yuangongrizhi where 1 "; 
    if($shijian!=null)
    {
    $strsql.="and shijian='$shijian'";
    }
    if($name!=null)
    {
    $strsql.="and name='$name'";
    }
    if($bumen!=null)
    {
    $strsql.="and bumen='$bumen'";
    }
    $total = mysql_fetch_array(mysql_query($strsql)); //查询中条数
    include("tpl.pages.php");
    $myconn=mysql_connect("localhost","root","123456");
    mysql_select_db("rizhi",$myconn);
    mysql_query("set names'gbk'");
    $sql="select * from yuangongrizhi where 1 "; 
    if($bumen!=null)
    {
    $sql.="and bumen='$bumen'";
    }}
    if($shijian!=null)
    {
    $sql.="and shijian='$shijian'";
    }
    if($name!=null)
    {
    $sql.="and name='$name'";
    }
    $sql1=$sql."limit $startnum,$perpagenum";
    $result=mysql_query($sql1,$myconn);
    $i=$perpagenum*($page-1)+1; 
    while($row=mysql_fetch_array($result))
    { $id=$row['rizhiid'];
    ?>
        <tr>
          <td align="center" height="19"><?echo $row['name']?></td>
          <td align="center" height="19"><?echo $row['bumen']?></td>
          <td align="center" height="19"><?echo $row['zhiwu']?></td>
          <td align="center" height="19"><?echo $row['shijian']?></td>
          <td align="center"><?echo $row['shifoushenhe']?></td>
          <td align="center"><?echo $row['shenheshijian']?></td>
          <td align="center"><?echo $row['shenheren']?></td>
          <td align="center"><?echo $row['zhuangtai']?></td>
          <td align="center" height="19"><a href="tpl.rizhixiangxi.php?id=<?php echo $id;?>">详细信息</a></td>
          <td align="center"><a href="tpl.rizhichaxun.php?id=<?php echo $id?>&shifoushenhe=<?php echo $row['shifoushenhe']?>">删除</a></td>
    </tr>
        <?

        ?>
      </table>
    </form>
    <?php 
    echo $xian;
    ?>
      

  3.   

    /*分页函数
    $num:总共多少篇
    $p:当前页码
    $q:当前搜索的内容
    $str:地址url参数(问号后面的东西)
    $pn:每页显示数量
    {fl($num,$p,$q,$pn)}
    */
    function fy($num,$p,$str='?mod=zzwla&dosubmit=1',$q='',$pn=10)
    {
        if(empty($num)) return false;
        $ps=ceil($num/$pn);
        $q = $q ? '&q='.urlencode($q) : '';
        if($p>1)
            echo '<a href="'.$str.$q.'&p='.($p-1).'"> 上一页 </a>';
        if($ps<15)
            for($i=1;$i<15;++$i)
            {
                if($i<=$ps)
                    echo '<div class="'.($i==$p ? ('page pc"> '.$i.' '):('page"><a href="'.$str.$q.'&p='.$i.'"> '.$i.' </a>')).'</div>';
            }
        else
            for($i=$p-7;$i<$p+7;++$i)
            {
                if($i>0 && $i<=$ps)
                    echo '<div class="'.($i==$p ? ('page pc"> '.$i.' '):('page"><a href="'.$str.$q.'&p='.$i.'"> '.$i.' </a>')).'</div>';
            }
        if($p!=$ps)
            echo '<a href="'.$str.$q.'&p='.($p+1).'"> 下一页 </a>';
    }
    这个也可以的~
      

  4.   

    $str怎么得到,传到那里(具体代码)