本帖最后由 mini_110 于 2010-08-16 16:18:02 编辑

解决方案 »

  1.   

    看到这题,麻木了。每个学php 的必过的一关。
      

  2.   

    我的意思是 通过搜索后查询到的数据,当翻页的时候显示的并不是要搜索的数据,而是查询到的全部数据。
    echo "<table  border=1 width=700 cellspacing=0 style=border-collapse:collapse>";
    echo "<tr style=background-image:url(img/new_hader_27.jpg) height=30 style=color:#ffffff><th>选择</th><th>hotel_id</th><th>start_date</th><th>end_date</th><th>content</th><th>source</th><th>s_type</th><th>操作</th></tr>"; //查询数据
    if( empty($ziduan) || empty($txt_sousuo))
    $query = "SELECT * FROM hotel_activities_2";
    else
    $query = "SELECT * FROM hotel_activities_2 where $ziduan like '%{$txt_sousuo}%'";
    $result=mysql_query($query) or die("<script>alert('查询的数据不存在');window.location='chaxun_rizhi.php';</script>"); 
        $rowsPerPage=5;
        $maxRowCount=mysql_num_rows($result);
        if($maxRowCount%$rowsPerPage==0)
           {
           $maxPage=(int)($maxRowCount/$rowsPerPage);
           }
        else {
           $maxPage=(int)($maxRowCount/$rowsPerPage)+1;
              }
    if (isset($_GET['curPage']))
    {
    $page=$_GET['curPage'];
    }
    else 
        {
    $page=1;
        }
          $start=$rowsPerPage*($page-1);$sel1 = $query . " order by h_id limit $start,$rowsPerPage";$result=mysql_query($sel1) or die("查询失败");
    //循环输出表中各个字段值
    echo '<form action="delect_sj.php" method=post>';
    while ($row = mysql_fetch_array($result)) {
        echo '<tr align="center" class="shu">';
        echo '<td><input type=checkbox name="hid[]" value="'.$row['h_id'].'"></td>';
        echo '<td>'.$row['hotel_id'].'</td>';
        echo '<td>'.$row['start_date'].'</td>';
        echo '<td>'.$row['end_date'].'</td>';
        echo '<td>'.$row['content'].'</td>';
        echo '<td>'.$row['source'].'</td>';
        echo '<td>'.$row['s_type'].'</td>';
        echo '<td>'.'&nbsp;<a href="upedit.php?hid='.$row['h_id'].'" >编辑</a>&nbsp;'.'</td>';
        echo '</tr>';
    }
    echo '<input type=submit value="删除所选" onclick="return  delconfirm()"></form>';
    if( empty($ziduan) || empty($txt_sousuo))
    $query = "SELECT count(*) FROM hotel_activities_2";
    else
    $query = "SELECT count(*) FROM hotel_activities_2 where $ziduan like '%{$txt_sousuo}%'";
    $res=mysql_query("$query",$connection); 
    $row = mysql_fetch_array($res); 
    $numrows=$row[0]; 
    $pages=intval($numrows/$rowsPerPage); 
    if ($numrows%$rowsPerPage) 
    $pages++; if($page>1)
    {
    $prevPage=$page-1;
    echo "<a href='?curPage=$prevPage'><img src='img/prev.gif'/></a>";
    }
    if ($page<$maxPage)
    {
    $nextPage=$page+1;
    echo "<a href='?curPage=$nextPage'><img src='img/next.gif'/></a>";
    }
    echo "</table>";
    echo "<div align='left' class='shu'>共有".$pages."页&nbsp;当前为第".$page."页"; 
      

  3.   

    你查询后的参数没有带过去 你输出sql语句 在第一页跟第二页看下有什么不同 就知错在那
      

  4.   

    if( empty($ziduan) || empty($txt_sousuo))
        $query = "SELECT * FROM hotel_activities_2";
    else
        $query = "SELECT * FROM hotel_activities_2 where $ziduan like '%{$txt_sousuo}%'";
    这里我不知道你的$ziduan和$txt_sousuo是哪来的数据.但我大概知道中间要用and而不是or,如果用||也就是or,根本没办法运行到else那去..