Directory of Real Estate Agents / Brokers / Realtors in Sri Lanka
global $ifSearch, $getCity, $getNoPr, $getMinPr, $getMaxPr, $getBR, $getNEW, $getSP, $getAC,$getLX, $getUrgent, $getAvailNow, $searchWords, $location_flag, $getAgentType, $postedDate; if ($ifSearch == 1 && $searchbox == '') $getCity = ''; //if the city is removed from searchbox, then ignore the data from pervious search stored in location //build location search query if(!empty($searchbox)){ $sql_radius = mysqli_query($dbconn_i,"SELECT name,flag,city FROM places_geo_codes WHERE name = '".mysqli_real_escape_string($dbconn_i,$searchbox)."' LIMIT 1"); if (mysqli_num_rows($sql_radius) > 0) { //if results found $result_radius = mysqli_fetch_array($sql_radius); if ($dist == 0 || empty($dist)){ $dist = '1'; }else{ $dist = $dist; } $location_flag = $result_radius['flag']; $location_city = $result_radius['city']; $_SESSION['place_search'] = 1; }else{ $_SESSION['place_search'] = 0; $location_flag = ''; } } if ($getCity == '') { $sql_citysearch = ''; $titleCity = 'Sri Lanka'; } else if ($dist > 0 && ($location_flag == 'School' || $location_flag == 'Hospital')) { if($dist == '1'){ if (strpos($location_city,'Colombo') !== false) { $location_dist = 0.5; }else{ $location_dist = 1.8; } }else{ $location_dist = $dist; } $sql_citysearch = " AND city IN ( SELECT city_name from ( SELECT cities.city_name, ( 3959 * acos( cos( radians(".mysqli_real_escape_string($dbconn_i,$getCityLat).") ) * cos( radians( cities.city_lat ) ) * cos( radians( cities.city_lon ) - radians(".mysqli_real_escape_string($dbconn_i,$getCityLon).") ) + sin( radians(".mysqli_real_escape_string($dbconn_i,$getCityLat).") ) * sin( radians( cities.city_lat ) ) )) as distance FROM cities having distance < ".mysqli_real_escape_string($dbconn_i,$location_dist)." ORDER BY distance ) AS filter_city_name )"; $titleCity = $getCity; $textDist = " plus ".$dist."km radius"; } else if ($getCity != '' && $dist > 0 && $getCityLat !='' && $getCityLon != '') { $sql_citysearch = " AND city IN ( SELECT city_name from ( SELECT cities.city_name, 3956 * 2 * ASIN(SQRT( POWER(SIN((".mysqli_real_escape_string($dbconn_i,$getCityLat)." -abs(cities.city_lat)) * pi()/180 / 2), 2) +COS(".mysqli_real_escape_string($dbconn_i,$getCityLat)." * pi()/180) * COS(abs(cities.city_lat) * pi()/180) *POWER(SIN((".mysqli_real_escape_string($dbconn_i,$getCityLon)." -cities.city_lon) * pi()/180 / 2), 2) )) as distance FROM cities having distance < ".mysqli_real_escape_string($dbconn_i,$dist)." ORDER BY distance ) AS filter_city_name )"; $titleCity = $getCity; $textDist = " plus ".$dist."km radius"; } else if ($getRegion == 'Geo' && $getCityLat !='' && $getCityLon != '') { if ($dist == 0) $dist = 1; else $dist = $dist; //search for 1 km radius if radius not set $sql_citysearch = " AND city IN ( SELECT city_name from ( SELECT cities.city_name, 3956 * 2 * ASIN(SQRT( POWER(SIN((".mysqli_real_escape_string($dbconn_i,$getCityLat)." -abs(cities.city_lat)) * pi()/180 / 2), 2) +COS(".mysqli_real_escape_string($dbconn_i,$getCityLat)." * pi()/180) * COS(abs(cities.city_lat) * pi()/180) *POWER(SIN((".mysqli_real_escape_string($dbconn_i,$getCityLon)." -cities.city_lon) * pi()/180 / 2), 2) )) as distance FROM cities having distance < ".mysqli_real_escape_string($dbconn_i,$dist)." ORDER BY distance ) AS filter_city_name )"; $titleCity = $getCity; $textDist = " plus ".$dist."km radius"; } else if ($dist == '-1' || $getCity == '0') { $sql_citysearch = " AND region = '".mysqli_real_escape_string($dbconn_i,$getRegion)."'"; //if region_0 city sent, if region selected from drop down or search area = 'entre province' if ($getRegion == 'Colombo All') $titleCity = "Colombo"; else $titleCity = $getRegion." province"; } else if ($tab == 'wanted' || $tab == 'agents' || $tab == 'services') { $sql_citysearch = " AND ((city = '".mysqli_real_escape_string($dbconn_i,$getCity)."') OR city = 'any'))"; $titleCity = $getCity; } else { $sql_citysearch = " AND city = '".mysqli_real_escape_string($dbconn_i,$getCity)."'"; $titleCity = $getCity; } //select correct price field for rentals & land if ($tab == 'rentals') $sql_price = "price_monthly"; else if ($tab == 'land' && $land_pr_type == 'pp') $sql_price = "price_land_pp"; else if ($tab == 'land' && $land_pr_type == 'pa') $sql_price = "price_land_pa"; else if ($tab == 'land' && $land_pr_type == 'total') $sql_price = "price_land_total"; else $sql_price = "price"; //if no price for per acre, don't show it if ($tab == 'land' && $land_pr_type == 'pa') $acre_price = " AND price_land_pa > 0"; else $acre_price = ''; //price search //$getnoprice = ($getNoPr == 'Y') ? ' >= ' : ' > '; //If include no price, then >=0, else >0 $sql_getnoprice = ($getNoPr == 'Y') ? " OR price = 0" : ''; //OR price = 0 if (($getMinPr != 0 && (is_numeric($getMinPr))) || ($getMaxPr != 0 && (is_numeric($getMaxPr)))) { //if min price or max price has been entered.. //if ($getMinPr == '' || !(is_numeric($getMinPr))) $getMinPr = 0; if ($getMaxPr == 0 || !(is_numeric($getMaxPr))) $getMaxPr = 999999999999; if ($getMinPr == '') $getMinPr = 0; //fix intermittant bug $sql_getminmaxprice = " AND ((".$sql_price." >= ".mysqli_real_escape_string($dbconn_i,$getMinPr)." AND ".$sql_price." <= ".mysqli_real_escape_string($dbconn_i,$getMaxPr).")".mysqli_real_escape_string($dbconn_i,$sql_getnoprice)." ".$acre_price.")"; //AND (price >= 0 AND price < 999999999) } else $sql_getminmaxprice = ''; //type $getType = mysqli_real_escape_string($dbconn_i,$getType); //escaped here or else it'll escape the ' added below $getTypeArr = explode(',', $getType); if (count($getTypeArr) > 1) { foreach ($getTypeArr as $getTypeSin) { $sql_type_str .= "'".$getTypeSin."',"; } $sql_type_str = rtrim($sql_type_str, ','); //remove trailing comma } else $sql_type_str = "'".$getTypeArr[0]."'"; //the first record of only 1 /*if ($getType == 'House') $sql_type = " AND propty_type IN ('House', 'Bungalow', 'Annexe', 'Villa')"; //search all these types else if ($getType == 'Commercial') $sql_type = " AND propty_type IN ('Commercial', 'Hotel')"; else if ($getType == 'Apartment') $sql_type = " AND propty_type IN ('Apartment', 'Studio')"; else if ($getType == 'Bare land') $sql_type = " AND propty_type IN ('Bare land', 'Beachfront land')"; else if (isset($getType) && $getType != 'all' && $getType != '') $sql_type = " AND propty_type = '".mysqli_real_escape_string($getType)."'";*/ if (isset($getType) && $getType != 'all' && $getType != '') $sql_type = " AND propty_type IN (".$sql_type_str.")"; else $sql_type = ''; //$sql_type = (isset($getType) && $getType != 'all' && $getType != '') ? " AND propty_type = '".mysqli_real_escape_string($getType)."'" : ''; //bedrooms $sql_br = ($getBR != 0) ? " AND rooms >= ".mysqli_real_escape_string($dbconn_i,$getBR)."" : ''; //extras $extra_new = ($getNEW == 'Y') ? " AND NEW = 'Y'" : ''; $extra_SP = ($getSP == 'Y') ? " AND SP = 'Y'" : ''; $extra_AC = ($getAC == 'Y') ? " AND AC = 'Y'" : ''; $extra_LX = ($getLX == 'Y') ? " AND luxury = 'Y'" : ''; $extra_urgent = ($getUrgent == 'Y') ? " AND avail = 'For Urgent Sale'" : ''; $extra_avail = ($getAvailNow == 'Y') ? " AND avail IN ('Available Now', 'For Urgent Sale', 'Price Reduced')" : ''; $sql_extras = $extra_new.$extra_SP.$extra_AC.$extra_LX.$extra_urgent.$extra_avail; if ($searchWords != '') { $sql_searchwords = " MATCH(`desc`, `heading`,`city`) AGAINST('+".mysqli_real_escape_string($dbconn_i,$searchWords)."' IN BOOLEAN MODE) AND"; if($getType != 'agents'){ $sql_searchwords_select = ",MATCH(`desc`, `heading`,`city`) AGAINST ('".mysqli_real_escape_string($dbconn_i,$searchWords)."') AS score"; $sql_order = "ORDER BY priority DESC, score DESC"; } } else if (($getMinPr > 0 && $getMaxPr > 0) && ($tab == 'rentals' || $tab == 'land')) $sql_order = "ORDER BY price_monthly,price_land_pp ASC"; else if ($getMinPr > 0 && $getMaxPr > 0) $sql_order = "ORDER BY price"; else if ($tab == 'home') $sql_order = "ORDER BY is_showcase DESC"; else if ($location_flag == 'School') $sql_order = ""; else { $sql_searchwords = ""; $sql_searchwords_select = ''; //$sql_order = 'ORDER BY priority DESC, thumb DESC, submit_date DESC'; $sql_order = 'ORDER BY priority DESC, u.verified,pic, submit_date DESC'; } //land $sql_extra_land = ($tab == 'land') ? ',size_land,land_units' : ''; //members only for agents if ($tab == 'agents') $agents_members = " AND membership > 3"; else $agents_members = ''; //services_extra $services_extra = ($getAgentType != '' && ($tab == 'agents' || $tab == 'services')) ? " AND (service_type LIKE '%".mysqli_real_escape_string($dbconn_i,$getAgentType)."%' OR service_type = '')" : ""; if ($tab == 'services') { $services_extra .= " AND propty_type <> 'agents' AND (priority > 0 OR membership >= 3)"; //only paid ads for services $tab = 'agents'; //this makes 'type='agents'' } $sql_services_extra = ($tab == 'agents' || $tab == 'services') ? ',service_type' : ''; //applies to both agents and services //agents and valuers authorisations if ($tab == 'agents' || $tab == 'services') { //$services_auth_join = " LEFT JOIN services_auth s ON a.ad_id = s.ad_id"; //$services_auth_join = " AND validated IN (SELECT validated FROM services_auth WHERE ad_id = a.ad_id LIMIT 1) "; $services_auth_join = ""; //$services_auth_select = ",validated,auth_exp"; $services_auth_select = ",(SELECT validated FROM services_auth WHERE services_auth.ad_id = a.ad_id AND auth_exp >= CURDATE() LIMIT 1) AS validated"; } else { $services_auth_join = ""; $services_auth_select = ""; } //posted date if ($postedDate > 0) { $date_search = mktime(0,0,0,date("m"),date("d")-$postedDate,date("Y")); $sql_posted_date = " AND posted_date > '".date("Y-m-d", $date_search )."'"; } else $sql_posted_date = ''; //showcase if ($tab == 'home') { $showcase = " AND is_showcase > 0"; $tab = '%_%'; } else { $showcase = ''; } ?>
4 Bedroom bungalow for sale in karandeniya
VERIFIED

Area(s) if($tab_link == 'agents') echo("covered"); ?>: karandeniya
4 Bedroom bungalow for sale in karandeniya.... More »
3 Bedroom house for sale in Matara
VERIFIED

Area(s) if($tab_link == 'agents') echo("covered"); ?>: Matara,Galle,Elpitiya
3 Bedroom 1650 sqft house for sale in Matara.... More »
Sarasi Lands Private Limited
VERIFIED

Area(s) if($tab_link == 'agents') echo("covered"); ?>:
Sarasi Lands Private LimitedSarasi Lands Private LimitedSarasi Lands Private LimitedSarasi Lands Private LimitedSarasi Lands Private LimitedSarasi Lands Private LimitedSarasi Lands.... More »