<?php 
if(is_integer($HotelID)){echo "why";}
global $currentpage,$totalPut,$pagecount;
global $result;
global $HotelID, $Name, $Boss, $President, $Address, $Tel, $DOSTel, $Status, $Rooms, $Beds, $Grade, $Picture, $CSO, $StarLevel ;
include("../inc/header1.inc");
session_start();
if (!isset($session1)){ echo Header("Location: ../common/Error.asp?code=6");}
else{
for ($i=0;$i<count($session1);$i++){
   if ($session1[$i]=='12'){break;}
   if($i==count($session1)){echo Header("Location: ../common/Error.asp?code=6");}
   }
}
if (isset($province)){$code=$province;}
if (isset($province)&&isset($city2)){$code=$code.trim($city2);}
$a=strlen($code);
if (isset($page)){
   if ($page>1){$page=$page;}
   else{ $page=1;}
   }
$SqlText1 = "SELECT HotelID, Name, Boss, President, Address, Tel, DOSTel, Status, Rooms, Beds, Grade, Picture, CSO, StarLevel FROM tHotelInfo";
if (($HotelID) ||($Name) || ($Boss) ||($President) ||($Address)|| ($Rooms) || ($Grade) || ($StarLevel) || ($province) ){
$SqlText1 .=" where ";
  if ($HotelID){
  if ($HotelID>0){
  $SqlText1 = $SqlText1 ." HotelID like '%".$HotelID."%'and ";}
  else{ $SqlText1 = $SqlText1 ." HotelID like '%".$HotelID."%' and ";}
  }
  if ($Name){ $SqlText1 = $SqlText1 ." name like '%".$Name."%' and ";}
  if ($Boss){ $SqlText1 = $SqlText1. " Boss like '%" .$Boss."%'and ";}
  if ($President){ $SqlText1 = $SqlText1 . " President ='" . $President . "'and ";}
  if ($Address){ $SqlText1 = $SqlText1 ." Address like '%" .$Address. "%'and ";}
  if ($Rooms){ $SqlText1 = $SqlText1. "  Rooms ='". $Rooms."'and ";}
  if ($Grade){ $SqlText1 = $SqlText1. "  Grade ='" .$Grade ."'and ";}
  if ($a>0 && $a<3 ){ 
   $SqlText1 = $SqlText1 ." left(hotelid,2)='".$code."' and ";}
   elseif ($a>0 && $a>3 ){
   $SqlText1 = $SqlText1 ." left(hotelid,6)='".$code."' and ";}
  if ($StarLevel){ $SqlText1 = $SqlText1 . " StarLevel ='" .$StarLevel ."'and ";}
$SqlText1=substr($SqlText1 ,0,-4);
//$SqlText1="SELECT HotelID, Name, Boss, President, Address, Tel, DOSTel, Status, Rooms, Beds, Grade, Picture, CSO, StarLevel FROM tHotelInfo where HotelID like '%6203033434%'";}
else{
$free=true;
}
if  (!isset($show)){echo "df";}
else{?>
<?php
function showpage($totalnumber,$maxperpage,$filename){
global $HotelID, $Name, $Boss, $President, $Address, $Tel, $DOSTel, $Status, $Rooms, $Beds, $Grade, $Picture, $CSO, $StarLevel ,$province,$city2,$page;
echo $Boss;
if (isset($page)){}
else{$page=1;}
  //dim n
  if ($totalnumber % $maxperpage){
     $n= $totalnumber / $maxperpage+1;}
  else{
     $n= $totalnumber / $maxperpage;}
 if($page>$n){$page=$n;}
 echo "<form method=Post action=".$filename."?HotelID=$HotelID&Name=$Name&Boss=$Boss&President=$President&Address=$Address&Rooms=$Rooms&Grade=$Grade&StarLevel=$StarLevel&province=$province&city2=$city2&show=full>";//."?&HotelID=".$HotelID."&Name=".$Name."&Boss=".$Boss."&President=".$President."&Address=".$Address."&Rooms=".$Rooms."$grade=".$Grade."&StarLevel=".$StarLevel."&province=".$province."&city2=".$city2."&show=full>";
 
  echo  "<p align='center'>| 分页 | .$page";
  if ($page<2){// then
    echo  "<font color='999966'>首页 | 上一页 | </font>";}
  else {
  echo " <a href=$filename?page=1&HotelID=$HotelID&Name=$Name&Boss=$Boss&President=$President&Address=$Address&Rooms=$Rooms&Grade=$Grade&StarLevel=$StarLevel&province=$province&city2=$city2&show=full>首页</a> ";//
  $sw=$page-1; 
   echo "<a href= $filename?page=".$sw."&HotelID=$HotelID&Name=$Name&Boss=$Boss&President=$President&Address=$Address&Rooms=$Rooms&Grade=$Grade&StarLevel=$StarLevel&province=$province&city2=$city2&show=full>上一页</a> ";//"
}
  if ($n-$page<1){// then
    echo "<font color='999966'>下一页 | 尾页 | </font>";}
  else{
  $sw=$page+1;
  echo "<a href=$filename?page=".$sw."&HotelID=$HotelID&Name=$Name&Boss=$Boss&President=$President&Address=$Address&Rooms=$Rooms&Grade=$Grade&StarLevel=$StarLevel&province=$province&city2=$city2&show=full>下一页| </a> ";//
  echo "<a href=$filename?page=".$n."&HotelID=$HotelID&Name=$Name&Boss=$Boss&President=$President&Address=$Address&Rooms=$Rooms&Grade=$Grade&StarLevel=$StarLevel&province=$province&city2=$city2&show=full>尾页 | </a> ";//
  }
 echo "&nbsp;页次:<strong><font color=red>".$page."</font>/".$n."</strong>页 | ";
echo  "&nbsp;共<b>".$totalnumber."</b>条记录 | <b>".$maxperpage."</b>条记录/页 | ";
   echo  " 转到:<input type='text' name=page size=4 maxlength=10 class=smallInput value=".$page.">";
   echo  "<input class=buttonface type='submit'  value=' Go '  name='cndok'></span></p></form>"   ;   
}?>
<table width="760" border="0" cellspacing="0" cellpadding="0" height="120">
  <tr>
    <td height="64"> 
      <table border="0" cellspacing="1" width="760">
        <tr bgcolor="#C7DAED"> 
          <td height="22" class="text1"> 
            <p align="center"><strong><span class="font2"><font color="#FFFFFF"><span class="font2"><font color="#000000" class="font1">查询列表</font></span></font></span></strong> 
          </td>
        </tr>
        <tr> 
          <td class="text1" height="105"><br>
  <?php 
   static $MaxPerPage=1;
  if (isset($page)){$currentpage=$page;}
  else{$currentpage=1;}
$result=mssql_query($SqlText1) or die ("Unable to");
if (mssql_num_rows($result)<1){echo "<p align='center'>  没有找到任何记录</p><center><a href=javascript:history.go(-1)>返回</a>";}
else{
$rows=mssql_num_rows($result);
$totalput=$rows;
function showContent(){
   $i=0;
global $result;
global $MaxPerPage,$page,$currentpage;
$wwww=mssql_num_rows($result);
?>
            <center>
                <table width="760" border="0" cellspacing="0" bgcolor="#999999">
                  <tr>
                    <td>
                      <table cellspacing="1" width="760" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" class="text1">
                        <tr bgcolor="f3f3f3" class="font1"> 
                          
                        <td  align="center"  height="25" bgcolor="f3f3f3" width="125"><b>旅馆编码</b></td>
                          <td  align="center" height="25" width="180" ><b>旅馆名称</b></td>
                          <td  align="center" height="25" width="140" ><b>地址</b></td>
                          <td  align="center" height="25" width="140"><b>法定代表人</b></td>
                          <td  align="center" height="25" width="140"><b>负责人</b></td>
<td  align="center" height="25" width="140" ><b>旅馆等级</b></td>
                          <td  align="center" height="25" width="140" ><b>旅馆星级</b></td>
                          <td  align="center" height="25" width="140"><b>房间数</b></td>
                        </tr>
                     <?php
 if($page>1){
 mssql_data_seek($result,$page-1);}
 while($values=mssql_fetch_array($result)){//&&($i<=$MaxPerPage))  do while not rs.eof
 ?>
                        <tr > 
                          <td align="center"  bgcolor="f3f3f3"> <a href="hotelinfo.asp?HotelID=<?php echo $values["HotelID"]?>"><?php echo $values["HotelID"]?></a> 
                          </td>
                          <td align="center"  bgcolor="f3f3f3">
<?php
if (strlen($values["Name"])>8){//if len($values["Name"))>8 then
      echo substr($values["Name"],0,6)."...";}
else {
  echo $values["Name"];
 }
  ?>
                          </td>   <td align="center"  bgcolor="f3f3f3">
   <?php  
    if (strlen($values["Address"])>7 ){//then
       echo substr($values["Address"],0,6)."...";}
 else {
   echo $values["Address"];
 }?>
                          </td> <td align="center"  bgcolor="f3f3f3"> <?php  echo $values["Boss"];?>
                          </td>
  <td align="center"  bgcolor="f3f3f3"><?php  echo $values["President"];?>
                          </td>
  <td align="center"  bgcolor="f3f3f3" >
  <?php  //Rs1.open "select * from thotelgradecode where code='".$values["Grade")."'",conn,1,1
$result1=mssql_query("select * from thotelgradecode where code='".$values["Grade"]."'");
if (mssql_num_rows($result1)){
$values2=mssql_fetch_array($result1);
echo $values2["Description"];}
else{echo "not Description";}//if not Rs1.eof then  echo  rs1("description")
mssql_free_result($result1);?>
                          </td>
  <td  align="center"  bgcolor="f3f3f3"> 
  <?php  //Rs1.open "select * from tstarcode where code='".$values["StarLevel")."'",conn,1,1
$result1=mssql_query("select * from tstarcode where code='".$values["StarLevel"]."'");
if (mssql_num_rows($result1)){
$values2=mssql_fetch_array($result1);
echo $values2["Description"];}
else{echo "not Description";}//if not Rs1.eof then  echo  rs1("description")
mssql_free_result($result1);?>
                          </td>
  <td  align="center"  bgcolor="f3f3f3"><?php  echo $values["Rooms"];?>
                          </td>
                        </tr>
                        <?php   
$i+=1;
if($i==$MaxPerPage){break;}
}
   ?>
   
                      </table>
                    </td>
                  </tr>
                </table>
              </center>
          
            <?php  //<?php echo "asdf";
  }?>
<?php
$totalput=$rows;
                 showpage ($totalput,$MaxPerPage,"hotelhtml22.php");
                 showContent();
                 showpage ($totalput,$MaxPerPage,"hotelhtml22.php");//}
// }
mssql_free_result($result);
    mssql_close();
}?>
 </td>
  </tr>
</table>
</td>
  </tr>
</table>
<?php }?>