PHP是高手的进.................... 本帖最后由 mini_110 于 2010-08-16 16:18:02 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 看到这题,麻木了。每个学php 的必过的一关。 我的意思是 通过搜索后查询到的数据,当翻页的时候显示的并不是要搜索的数据,而是查询到的全部数据。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>'.' <a href="upedit.php?hid='.$row['h_id'].'" >编辑</a> '.'</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."页 当前为第".$page."页"; 你查询后的参数没有带过去 你输出sql语句 在第一页跟第二页看下有什么不同 就知错在那 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那去.. PHP跟zend的问题(非常急) 一个Apache配置问题 大家谁对织梦网系统熟悉? 我的出现问题了! 请大哥大姐们帮下忙! php为什么插入不了中文 请教下搜读和快眼看书一类小说搜索网站的原理 mysql中怎么删除两个关联表中不相同的数据??? 一个不错的免费php+mysql空间 php中继承windows域用户,可以吗? 文件上传问题 thinkphp 后台登录验证功能想去掉 应去掉那个文件里的哪个代码 求PHP数组分组算法 为什么iestore.cn的IESTORE支付时选择Bank wire payment,在按下“I confirm payment”后会出现错误:
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>'.' <a href="upedit.php?hid='.$row['h_id'].'" >编辑</a> '.'</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."页 当前为第".$page."页";
$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那去..