if(isset($_REQUEST['act']) && $_REQUEST['act'] == 'search')
{
$sql = 'SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels ';
if(isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'vote')
$sql_sort = 'h.ovmedia DESC';
else
$sql_sort = 'h.name ASC';
if(isset($_REQUEST['name']) && $_REQUEST['name'] != '')
$sql .= "AND h.name LIKE '%".$_REQUEST['name']."%'";
//if(isset($_REQUEST['wopen']) && $_REQUEST['wopen'] == '1')
// $sql .= "AND h.allyearopen='1'";
if(isset($_REQUEST['idcat']) && $_REQUEST['idcat'] != '')
{
if($_REQUEST['idcat'] == 'exc_resorts_in')
$sql .= " AND h.exc_resorts_in='1'";
elseif($_REQUEST['idcat'] == 'resorts_in')
$sql .= " AND h.resorts_in='1'";
else
{
$cat_id = mysql_fetch_row(mysql_query("SELECT ID FROM categories WHERE pagename='".$_REQUEST['idcat']."'"));
$sql .= " AND h.idcategories='".$cat_id[0]."'";
}
}
if(isset($_REQUEST['board']) && $_REQUEST['board'] != '')
{
$board_id = mysql_fetch_row(mysql_query("SELECT ID FROM acc_type WHERE code='".$_REQUEST['board']."'"));
$sql .= " AND h.idacc_type='".$board_id[0]."'";
}
$query_comp = $sql." AND l.idlocations='".IDLOC."'";
$query_comp .= " ORDER BY ".$sql_sort;
$query = mysql_query($query_comp) or die(mysql_error());
//print $query_comp;
}
elseif(isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'listingname')
{
// show resorts by STAR
if($_REQUEST['type'] == 'resorts_in')
{
//$query = mysql_query("SELECT * FROM hotels WHERE resorts_in='1' AND resort_id>'0' ORDER BY stars DESC");
$limit = 10;
$numrows = mysql_num_rows(mysql_query("SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels AND h.status='1' AND l.idlocations='".IDLOC."' AND h.resorts_in='1' AND h.resort_id>'0' ORDER BY h.name ASC,h.stars DESC"));
$pagenow = ($_REQUEST['page']>1)?$_REQUEST['page']:1;
$limit_min = ($limit*$pagenow)-$limit;
$limit_max = $limit*$pagenow;
$limit_max_show = ($numrows < 10)?$numrows:$limit_max;
$end = ($limit_max < $numrows)?$limit_max:$numrows;
$query = mysql_query("SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels AND h.status='1' AND l.idlocations='".IDLOC."' AND h.resorts_in='1' AND h.resort_id>'0' ORDER BY h.name ASC,h.stars DESC LIMIT $limit_min,$limit") or die(mysql_error());
print "Found ".$numrows." hotels in category Resorts ";
print "show results from ".($limit_min+1)." to $limit_max_show";
}
elseif($_REQUEST['type'] == 'exc_resorts_in')
{
//$query = mysql_query("SELECT * FROM hotels WHERE exc_resorts_in='1' AND resort_id>'0' ORDER BY stars DESC");
$limit = 10;
$numrows = mysql_num_rows(mysql_query("SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels AND h.status='1' AND l.idlocations='".IDLOC."' AND h.exc_resorts_in='1' AND h.resort_id>'0' ORDER BY h.name ASC,h.stars DESC"));
$pagenow = ($_REQUEST['page']>1)?$_REQUEST['page']:1;
$limit_min = ($limit*$pagenow)-$limit;
$limit_max = $limit*$pagenow;
$limit_max_show = ($numrows < 10)?$numrows:$limit_max;
$end = ($limit_max < $numrows)?$limit_max:$numrows;
$query = mysql_query("SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels AND h.status='1' AND l.idlocations='".IDLOC."' AND h.exc_resorts_in='1' AND h.resort_id>'0' ORDER BY h.name ASC,h.stars DESC LIMIT $limit_min,$limit") or die(mysql_error());
print "Found ".$numrows." hotels in category Exclusive Resorts ";
print "show results from ".($limit_min+1)." to $limit_max_show";
}
else
{
$cat_id = mysql_fetch_row(mysql_query("SELECT ID,name FROM categories WHERE pagename='".$_REQUEST['type']."'"));
//$query = mysql_query("SELECT * FROM hotels WHERE idcategories='".$cat_id[0]."' AND resort_id>'0' ORDER BY stars DESC");
$limit = 10;
$numrows = mysql_num_rows(mysql_query("SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels AND h.status='1' AND l.idlocations='".IDLOC."' AND h.idcategories='".$cat_id[0]."' ORDER BY h.name ASC,h.stars DESC"));
$pagenow = ($_REQUEST['page']>1)?$_REQUEST['page']:1;
$limit_min = ($limit*$pagenow)-$limit;
$limit_max = $limit*$pagenow;
$limit_max_show = ($numrows < 10)?$numrows:$limit_max;
$end = ($limit_max < $numrows)?$limit_max:$numrows;
$query = mysql_query("SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels AND h.status='1' AND l.idlocations='".IDLOC."' AND h.idcategories='".$cat_id[0]."' ORDER BY h.name ASC,h.stars DESC LIMIT $limit_min,$limit") or die(mysql_error());
print "Found ".$numrows." hotels in category ".$cat_id[1]." ";
print "show results from ".($limit_min+1)." to $limit_max_show";
}
}
elseif(isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'board')
{
// show resorts by STAR
$board_id = mysql_fetch_row(mysql_query("SELECT ID,name FROM acc_type WHERE code='".$_REQUEST['type']."'"));
$limit = 10;
$numrows = mysql_num_rows(mysql_query("SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels AND h.status='1' AND l.idlocations='".IDLOC."' AND h.idacc_type='".$board_id[0]."' AND h.resort_id>'0' ORDER BY h.name ASC"));
$pagenow = ($_REQUEST['page']>1)?$_REQUEST['page']:1;
$limit_min = ($limit*$pagenow)-$limit;
$limit_max = $limit*$pagenow;
$limit_max_show = ($numrows < 10)?$numrows:$limit_max;
$end = ($limit_max < $numrows)?$limit_max:$numrows;
$query = mysql_query("SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels AND h.status='1' AND l.idlocations='".IDLOC."' AND h.idacc_type='".$board_id[0]."' AND h.resort_id>'0' ORDER BY h.name ASC");
print "Found ".$numrows." hotels with ".$board_id[1]." board type ";
print "show results from ".($limit_min+1)." to $limit_max_show";
}
elseif(isset($_REQUEST['location']) && $_REQUEST['location'] != '')
{
$zone = mysql_fetch_row(mysql_query("SELECT idcity,zone FROM cityzone WHERE ID='".$_REQUEST['zone_id']."'"));
$limit = 10;
$numrows = mysql_num_rows(mysql_query("SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels AND h.status='1' AND l.idlocations='".IDLOC."' AND h.idcityzone='".$_REQUEST['zone_id']."' AND h.resort_id>'0' ORDER BY h.name ASC"));
$pagenow = ($_REQUEST['page']>1)?$_REQUEST['page']:1;
$limit_min = ($limit*$pagenow)-$limit;
$limit_max = $limit*$pagenow;
$limit_max_show = ($numrows < 10)?$numrows:$limit_max;
$end = ($limit_max < $numrows)?$limit_max:$numrows;
$query = mysql_query("SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels AND h.status='1' AND l.idlocations='".IDLOC."' AND h.idcityzone='".$_REQUEST['zone_id']."' AND h.resort_id>'0' ORDER BY h.name ASC");
print "Found ".$numrows." hotels located in ".$zone[1]." ";
print "show results from ".($limit_min+1)." to $limit_max_show";
}
?>
if( (isset($_REQUEST['act']) && $_REQUEST['act'] == 'search') && (isset($_REQUEST['price']) && $_REQUEST['price'] > 0))
{
$sql2 = 'SELECT * FROM hotels h,hotels_locations l WHERE h.ID=l.idhotels ';
if(isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'hotel')
$sql_sort2 = 'h.name ASC';
elseif(isset($_REQUEST['sortby']) && $_REQUEST['sortby'] == 'vote')
$sql_sort2 = 'h.ovmedia DESC';
if(isset($_REQUEST['name']) && $_REQUEST['name'] != '')
$sql2 .= "AND h.name LIKE '%".$_REQUEST['name']."%'";
//if(isset($_REQUEST['wopen']) && $_REQUEST['wopen'] == '1')
// $sql2 .= "AND h.allyearopen='1'";
if(isset($_REQUEST['idcat']) && $_REQUEST['idcat'] != '')
{
if($_REQUEST['idcat'] == 'exc_resorts_in')
$sql2 .= " AND h.exc_resorts_in='1'";
elseif($_REQUEST['idcat'] == 'resorts_in')
$sql2 .= " AND h.resorts_in='1'";
else
{
$cat_id = mysql_fetch_row(mysql_query("SELECT ID FROM categories WHERE pagename='".$_REQUEST['idcat']."'"));
$sql2 .= " AND h.idcategories='".$cat_id[0]."'";
}
}
if(isset($_REQUEST['board']) && $_REQUEST['board'] != '')
{
$board_id2 = mysql_fetch_row(mysql_query("SELECT ID FROM acc_type WHERE code='".$_REQUEST['board']."'"));
$sql2 .= " AND h.idacc_type='".$board_id[0]."'";
}
$sql2.= " AND l.idlocations='".IDLOC."'";
// show hotels by price
$hotel_with_price = array();
$hotel_with_no_price = array();
while($row = mysql_fetch_array($query))
{
$price_adult_prz = ($_SESSION['prz'] != '')?"adult_price_2_".$_SESSION['prz']:"adult_price_2";
if(isset($_REQUEST['theDate']) && $_REQUEST['theDate'] != '')
{
$season = mysql_fetch_row(mysql_query("SELECT codenum FROM periods2 WHERE idhotels='".$row[0]."' AND pday='".$_REQUEST['theDate']."'"));
$min_price = mysql_fetch_array(mysql_query("SELECT MIN(".$price_adult_prz.") FROM prices2 WHERE idhotels='".$row[0]."' AND period_codenum='".$season[0]."'"));
$price_adult = sprintf("%.2f",($min_price[0]/2));
}
else
{
$min_price = mysql_fetch_row(mysql_query("SELECT MIN($price_adult_prz) FROM prices2 WHERE idhotels='".$row[0]."'"));
$price_adult = sprintf("%.2f",($min_price[0]/2));
}
if(isset($_REQUEST['hoteltype']) && $_REQUEST['hoteltype'] > 0)
{
$check_htp = mysql_fetch_row(mysql_query("SELECT ID FROM hoteltype_list WHERE idhotels='".$row[0]."' AND idhoteltype='".$_REQUEST['hoteltype']."'"));
if($check_htp[0] > 0)
{
if($_REQUEST['price'] >= $price_adult)
$hotel_with_price[$row[0]] = $price_adult;
elseif($price_adult > 0)
$hotel_with_no_price[$row[0]] = $price_adult;
elseif($price_adult == 0)
$hotel_with_no_price[$row[0]] = 0;
}
}
else
{
if($_REQUEST['price'] >= $price_adult)
$hotel_with_price[$row[0]] = $price_adult;
elseif($price_adult > 0)
$hotel_with_no_price[$row[0]] = $price_adult;
elseif($price_adult == 0)
$hotel_with_no_price[$row[0]] = 0;
}
}
asort($hotel_with_price);
$all_hotels = $hotel_with_price+$hotel_with_no_price;
foreach($all_hotels as $key=>$value)
{
//print "$key = $value ";
$hid[] = $key;
}
$hotels_ids = implode(',',$hid);
$limit = 10;
$numrows = count($all_hotels);
$pagenow = ($_REQUEST['page']>1)?$_REQUEST['page']:1;
$limit_min = ($limit*$pagenow)-$limit;
$limit_max = $limit*$pagenow;
$limit_max_show = ($numrows < 10)?$numrows:$limit_max;
$end = ($limit_max < $numrows)?$limit_max:$numrows;
$sql_htl.= $sql2." AND h.ID IN($hotels_ids) ORDER BY FIND_IN_SET(h.ID,'".$hotels_ids."') LIMIT $limit_min,$limit";
//print $sql_htl." ";
if($numrows > 0)
{
?>
Search results Found =$numrows?> hotels show results from =($limit_min+1)?> to =$limit_max_show?>"
$query_htl = mysql_query($sql_htl) or die(mysql_error());
while($row2 = mysql_fetch_array($query_htl))
{
$form_id = "form_".$row2[0];
$eab_icon = '';
$resort_id = 0;
$zone_name = mysql_fetch_row(mysql_query("SELECT zone FROM cityzone WHERE ID='".$row2['idcityzone']."'"));
$board_type = mysql_fetch_row(mysql_query("SELECT name FROM acc_type WHERE ID='".$row2['idacc_type']."'"));
if( (isset($_REQUEST['theDate']) && $_REQUEST['theDate'] != '') && (isset($_REQUEST['theDate2']) && $_REQUEST['theDate2'] != '') )
$eab = mysql_fetch_array(mysql_query("SELECT * FROM early_booking WHERE idhotels = '".$row2[0]."' AND '".date("Y-m-d",strtotime($_REQUEST['theDate']))."' BETWEEN eb_date_from AND eb_date_to AND eb_date>='".date("Y-m-d",time())."'"));
else
$eab = mysql_fetch_array(mysql_query("SELECT * FROM early_booking WHERE idhotels = '".$row2[0]."' AND eb_date>='".date("Y-m-d",time())."'"));
if($eab['eb_perc'] > 0 )
$eab_icon = "";
if($row2['resort_id'] < 1)
{
$check_last_res_id = mysql_fetch_row(mysql_query("SELECT MAX(resort_id) FROM hotels"));
$resort_id = $check_last_res_id[0]+1;
mysql_query("UPDATE hotels SET resort_id='".$resort_id."' WHERE ID='".$row2[0]."'") or die(mysql_error());
}
else
$resort_id = $row2['resort_id'];
?>
//check if in compare list
$check_comp = mysql_num_rows(mysql_query("SELECT * FROM compare_list WHERE idhotels='".$row2[0]."' AND session_id='".session_id()."' AND dateins='".date("Y-m-d",time())."'"));
if($check_comp > 0)
{
?>
See compare List
}
else
{
?>
Compare
}
?>
//check if in compare list
$check_comp = mysql_num_rows(mysql_query("SELECT * FROM compare_list WHERE idhotels='".$row[0]."' AND session_id='".session_id()."' AND dateins='".date("Y-m-d",time())."'"));
if($check_comp > 0)
{
?>
See compare List
}
else
{
?>
Compare
}
?>