function get($name){
return isset($_POST[$name])?$_POST[$name]:(isset($_GET[$name])?$_GET[$name]:"");
}
$ziduan= get('ziduan');
$txt_sousuo= get('txt_sousuo');$where = "where 1"; if(!empty($ziduan) && !empty($txt_sousuo))
{
$where .= " and $ziduan like '%{$txt_sousuo}%'";
}
$sql = "SELECT count(h_id) as countnum FROM hotel_activities_2 $where ";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
//printf("ID: %s Name: %s", $row[0]);
$countnum = $row['countnum'];
}
if($countnum == 0)
die("<script>alert('数据不存在');window.location='chaxun.php';</script>");
/*******************排序*************************/
$field="h_id";
if(isset($_REQUEST["field"]))
{
$field=$_REQUEST["field"];
}
$order="asc";
if(isset($_REQUEST["order"]))
{
$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);
$sel1 = "SELECT * FROM hotel_activities_2 $where order by ".$field." ".$order." limit $start,$rowsPerPage";
$result=mysql_query($sel1) or die("查询失败"); /*************************输出表格******************************/
echo '<form action="delect_sj.php" method="post">';
echo "<table border='1' width='800' cellspacing='0' style='border-collapse:collapse' id='tbColor'>";
echo "<tr style='background-image:url(img/left.jpg)' height='30' class='chaxun_head'>";
echo "<td width='100'><input name='allcheckbox' type='checkbox' title='全选/取消' onclick='cball(form)'>全选/取消</td>";
if($order=="asc")
{
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=hotel_id&order=desc" style="text-decoration: underline;">'.'酒店ID'.'</a>'.'</th>';
}
else{
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=hotel_id&order=asc" style="text-decoration: underline;">'.'酒店ID'.'</a>'.'</th>';
}
if($order=="asc")
{
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=start_date&order=desc" style="text-decoration: underline;">'.'开始时间'.'</a>'.'</th>';
}
else {
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=start_date&order=asc" style="text-decoration: underline;">'.'开始时间'.'</a>'.'</th>';
}
if($order=="asc")
{
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=end_date&order=desc" style="text-decoration: underline;">'.'结束时间'.'</a>'.'</th>';
}
else{
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=end_date&order=asc" style="text-decoration: underline;">'.'结束时间'.'</a>'.'</th>';
}
echo '<th width="150">'.'内容介绍'.'</th>'.'<th width="100">'.'备注'.'</th>'.'<th width="100">'.'s_type'.'</th>'.'<th width="50">'.'操作'.'</th>'.'</tr>';
$order=$_REQUEST["order"];
//循环输出表中各个字段值 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>'.date('Y-m-d', strtotime($row['start_date'])).'</td>';
echo '<td>'.date('Y-m-d', strtotime($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_houtai.php?hid='.$row['h_id'].'" >编辑</a> '.'</td>';
echo '</tr>';
}
echo "<div align='left' class='shu'>
<input type=submit value='删除所选' onclick='return check()'></form>";echo "<a href='?field=$field&order=$order&ziduan={$ziduan}&txt_sousuo=".rawurlencode($txt_sousuo)."&curPage=1' style='color:#FF0000'>首页</a>"." ";if($page>1) {
$prevPage=($page-1)<1?1:$page-1;
echo "<a href='?field=$field&order=$order&ziduan={$ziduan}&txt_sousuo=".rawurlencode($txt_sousuo)."&curPage=$prevPage'><img src='img/prev.gif'/></a>";
}
echo " "." ";
if ($page<$maxPage) {
$nextPage=($page+1)>$maxPage?$maxPage:$page+1;
echo "<a href='?field=$field&order=$order&ziduan={$ziduan}&txt_sousuo=".rawurlencode($txt_sousuo)."&curPage=$nextPage'><img src='img/next.gif'/></a>";
}
echo ""." <a href='?field=$field&order=$order&ziduan={$ziduan}&txt_sousuo=".rawurlencode($txt_sousuo)."&curPage=$maxPage' style='color:#FF0000'>尾页</a>"." ".""
?>
跳转至:
<select name="" onChange="document.location=this.value">
<option value="selected=selected"><?php echo "第".$page."页" ?></option>
<?php for ($i=1;$i<=$maxPage;$i++)
{
?>
<option value="<?php echo "?field=$field&order=$order&ziduan={$ziduan}&txt_sousuo=".rawurlencode($txt_sousuo)."&curPage=$i";?>"><?php echo "第".$i."页"?>
<?php }?>
</select>
<?php
echo "</div>";
echo "</table>";
echo "<div align='center' class='shu'>"."共".$maxPage."页 当前为第".$page."页"."</div>";
mysql_close($connection); //关闭与数据库的连接 */
return isset($_POST[$name])?$_POST[$name]:(isset($_GET[$name])?$_GET[$name]:"");
}
$ziduan= get('ziduan');
$txt_sousuo= get('txt_sousuo');$where = "where 1"; if(!empty($ziduan) && !empty($txt_sousuo))
{
$where .= " and $ziduan like '%{$txt_sousuo}%'";
}
$sql = "SELECT count(h_id) as countnum FROM hotel_activities_2 $where ";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result))
{
//printf("ID: %s Name: %s", $row[0]);
$countnum = $row['countnum'];
}
if($countnum == 0)
die("<script>alert('数据不存在');window.location='chaxun.php';</script>");
/*******************排序*************************/
$field="h_id";
if(isset($_REQUEST["field"]))
{
$field=$_REQUEST["field"];
}
$order="asc";
if(isset($_REQUEST["order"]))
{
$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);
$sel1 = "SELECT * FROM hotel_activities_2 $where order by ".$field." ".$order." limit $start,$rowsPerPage";
$result=mysql_query($sel1) or die("查询失败"); /*************************输出表格******************************/
echo '<form action="delect_sj.php" method="post">';
echo "<table border='1' width='800' cellspacing='0' style='border-collapse:collapse' id='tbColor'>";
echo "<tr style='background-image:url(img/left.jpg)' height='30' class='chaxun_head'>";
echo "<td width='100'><input name='allcheckbox' type='checkbox' title='全选/取消' onclick='cball(form)'>全选/取消</td>";
if($order=="asc")
{
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=hotel_id&order=desc" style="text-decoration: underline;">'.'酒店ID'.'</a>'.'</th>';
}
else{
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=hotel_id&order=asc" style="text-decoration: underline;">'.'酒店ID'.'</a>'.'</th>';
}
if($order=="asc")
{
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=start_date&order=desc" style="text-decoration: underline;">'.'开始时间'.'</a>'.'</th>';
}
else {
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=start_date&order=asc" style="text-decoration: underline;">'.'开始时间'.'</a>'.'</th>';
}
if($order=="asc")
{
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=end_date&order=desc" style="text-decoration: underline;">'.'结束时间'.'</a>'.'</th>';
}
else{
echo '<th width="100">'.'<a href="?ziduan='.$ziduan.'&txt_sousuo='.rawurlencode($txt_sousuo).'&field=end_date&order=asc" style="text-decoration: underline;">'.'结束时间'.'</a>'.'</th>';
}
echo '<th width="150">'.'内容介绍'.'</th>'.'<th width="100">'.'备注'.'</th>'.'<th width="100">'.'s_type'.'</th>'.'<th width="50">'.'操作'.'</th>'.'</tr>';
$order=$_REQUEST["order"];
//循环输出表中各个字段值 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>'.date('Y-m-d', strtotime($row['start_date'])).'</td>';
echo '<td>'.date('Y-m-d', strtotime($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_houtai.php?hid='.$row['h_id'].'" >编辑</a> '.'</td>';
echo '</tr>';
}
echo "<div align='left' class='shu'>
<input type=submit value='删除所选' onclick='return check()'></form>";echo "<a href='?field=$field&order=$order&ziduan={$ziduan}&txt_sousuo=".rawurlencode($txt_sousuo)."&curPage=1' style='color:#FF0000'>首页</a>"." ";if($page>1) {
$prevPage=($page-1)<1?1:$page-1;
echo "<a href='?field=$field&order=$order&ziduan={$ziduan}&txt_sousuo=".rawurlencode($txt_sousuo)."&curPage=$prevPage'><img src='img/prev.gif'/></a>";
}
echo " "." ";
if ($page<$maxPage) {
$nextPage=($page+1)>$maxPage?$maxPage:$page+1;
echo "<a href='?field=$field&order=$order&ziduan={$ziduan}&txt_sousuo=".rawurlencode($txt_sousuo)."&curPage=$nextPage'><img src='img/next.gif'/></a>";
}
echo ""." <a href='?field=$field&order=$order&ziduan={$ziduan}&txt_sousuo=".rawurlencode($txt_sousuo)."&curPage=$maxPage' style='color:#FF0000'>尾页</a>"." ".""
?>
跳转至:
<select name="" onChange="document.location=this.value">
<option value="selected=selected"><?php echo "第".$page."页" ?></option>
<?php for ($i=1;$i<=$maxPage;$i++)
{
?>
<option value="<?php echo "?field=$field&order=$order&ziduan={$ziduan}&txt_sousuo=".rawurlencode($txt_sousuo)."&curPage=$i";?>"><?php echo "第".$i."页"?>
<?php }?>
</select>
<?php
echo "</div>";
echo "</table>";
echo "<div align='center' class='shu'>"."共".$maxPage."页 当前为第".$page."页"."</div>";
mysql_close($connection); //关闭与数据库的连接 */
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货