PHP排序后翻页问题。。。。。。。。。。。。。。。。

xinshou_php 2010-08-25 05:45:29
排序都正常,但是一翻页或者按尾页,还是原来没排序的数据。
$field=$_REQUEST["field"];
if($field==""){
$field="id";
}
else{
$field=$_REQUEST["field"];
}

$order=$_REQUEST["order"];
if($order==""){
$order="asc";
}
else{
$order=$_REQUEST["order"];
}

$rowsPerPage=10;
$maxPage=ceil($countnum/$rowsPerPage);
$page=isset($_GET['curPage'])?intval($_GET['curPage']):1;
$page = $page<1?1:$page;
$page = $page>$maxPage?$maxPage:$page;

$start=$rowsPerPage*($page-1);
$sel = "SELECT * FROM hotel_rizhi $where1 order by ".$field." ".$order." limit $start,$rowsPerPage";
$result1=mysql_query($sel) or die("查询失败");
/******排序********/
echo "<table border=1 width=700 cellspacing=0 style=border-collapse:collapse id=tbColor>";
echo '<tr style=background-image:url(img/new_hader_27.jpg) height=30 class="chaxun_head">';
echo '<th width=50>'.'选择'.'</th>';
if($order=="asc"){
echo '<th width=120>'.'<a href="?field=hotel_id&order=desc" style="text-decoration: underline;">酒店ID</a>'.'</th>';
}else{
echo '<th width=120>'.'<a href="?field=hotel_id&order=asc" style="text-decoration: underline;">酒店ID</a>'.'</th>';
}
echo '<th width=80>'.'姓名'.'</th>';
echo '<th width=200>'.'内容介绍'.'</th>';
echo '<th width=75>'.'操作'.'</th>';
if($order=="asc"){
echo '<th width=75><a href="?field=time&order=desc" style="text-decoration: underline;">时间</a></th>';
}else{
echo '<th width=75><a href="?field=time&order=asc" style="text-decoration: underline;">时间</a></th>';
}
echo '</tr>';
//循环输出表中各个字段值
echo '<form action="delect_rz.php" method=post>';
while ($row = mysql_fetch_array($result1)) {
?>
<tr align="center" class="shu">
<td><input type=checkbox name="id[]" value=" <?php echo $row['id'] ?>"></td>
<td><?php echo $row['hotel_id']?></td>
<td><?php echo $row['name']?></td>
<td><?php echo $row['content']?></td>
<td><?php echo $row['operating']?></td>
<td><?php echo $row['time']?></td>
</tr>

<?php
}
echo '<input type=submit value="删除所选" onclick="return delconfirm()"></form>';
echo "<div align='left' class='shu'><a href='?rizhiziduan={$rizhiziduan}&txt_ss=".rawurlencode($txt_ss)."&curPage=1' style='color:#FF0000'>首页</a>"."  ";
if($page>1) {
$prevPage=($page-1)<1?1:$page-1;
echo"<a href='?rizhiziduan={$rizhiziduan}&txt_ss=".rawurlencode($txt_ss)."&curPage=$prevPage'><img src='img/prev.gif'/></a>";
}
echo " "." ";
if ($page<$maxPage) {
$nextPage=($page+1)>$maxPage?$maxPage:$page+1;
echo"<a href='?rizhiziduan={$rizhiziduan}&txt_ss=".rawurlencode($txt_ss)."&curPage=$nextPage'><img src='img/next.gif'/></a>";
}
echo ""."   <a href='?rizhiziduan={$rizhiziduan}&txt_ss=".rawurlencode($txt_ss)."&curPage=$maxPage' style='color:#FF0000'>尾页</a>"."   ".""
?>
...全文
41 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xinshou_php 2010-08-25
  • 打赏
  • 举报
回复
本人在线等
xinshou_php 2010-08-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 luciferstar 的回复:]
在翻页链接里,添加排序关键词。
[/Quote]
说明白点
LuciferStar 2010-08-25
  • 打赏
  • 举报
回复
在翻页链接里,添加排序关键词。

4,251

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧