Searh script

$mode=$_REQUEST['mode'];
if($mode=='top')
{
$hotsql="SELECT * FROM tbl_hotels WHERE fld_status='1'";
if($_REQUEST['stateid']!="")
{
$where.=" AND fld_state_id=".$_REQUEST['stateid']."";
}
if($_REQUEST['cityid']!="")
{
$cityid['fld_id']=$_REQUEST['cityid'];
$where.=" AND fld_city=".$_REQUEST['cityid']."";
}
if($_REQUEST['locationid']!="")
{
$where.=" AND fld_location=".$_REQUEST['locationid']."";
}
if($_REQUEST['categoryid']!="")
{
$where.=" AND fld_category=".$_REQUEST['categoryid']."";
}
if($_REQUEST['services']!="")
{
foreach($_REQUEST['services'] as $sval)
{
$wherese.=" FIND_IN_SET('$sval',fld_services) AND";
}
$where.=' AND'.substr($wherese,0,-3);
}
$hotelsql=$hotsql.$where;
}
else
{
$cityname=$_REQUEST['city'];
$hotelname=$_REQUEST['hotel'];
$type=$_REQUEST['type'];
$cityid=$obj_mysql->get_fetch_arr("SELECT * FROM tbl_city WHERE fld_city_name_en='$cityname'");
if($cityid!="" && $hotelname!="")
{
$hotelsql="SELECT * FROM tbl_hotels WHERE fld_city=".$cityid['fld_id']." AND fld_hotel_".$_SESSION['language']." LIKE '%".$hotelname."%'";
}
elseif($cityid=="" && $hotelname!="")
{
$hotelsql="SELECT * FROM tbl_hotels WHERE fld_hotel_".$_SESSION['language']." LIKE '%".$hotelname."%'";
}
elseif($cityid!="" && $hotelname=="")
{
$hotelsql="SELECT * FROM tbl_hotels WHERE fld_city=".$cityid['fld_id']." ";
}
elseif($type!="")
{
$hotelsql="SELECT * FROM tbl_hotels WHERE FIND_IN_SET('$type',fld_type) ";
}
else
{
$hotelsql="SELECT * FROM tbl_hotels ";
}


}

$hotelnum=$obj_mysql->get_num_rows($hotelsql);
$data=$obj_mysql->getAllData($hotelsql." ORDER BY RAND()");