'.$mywholequery);
if ( !$getlistings || mysqli_num_rows($getlistings) == 0 ) {
echo '
Sorry, we did not find any listings matching your search. Please try again, or search the MLS:
';
include 'searchbymls.php';
echo '
';
include 'searchform.php';
}
if ( $getlistings && mysqli_num_rows($getlistings) > 0 ) {
$howmany = mysqli_num_rows($getlistings);
echo 'We found '.$howmany . ' listings.
';
while ( $row = mysqli_fetch_assoc($getlistings) ) {
include 'listingtable.php';
echo '
';
}
include 'searchform.php';
}
include 'footer.php';
exit;
}
if (isset($proptype)) {
$myprop = $proptype.' Real Estate';
if ($proptype == 'Homes') {
$myprop = 'Homes';
} elseif ($proptype == 'Condos') {
$myprop = 'Condos';
} elseif ($proptype == 'Condominium') {
$myprop = 'Condos';
} elseif ($proptype == 'Lots' || $proptype == 'Land' ) {
$myprop = 'Land';
} elseif ($proptype == 'Commercial') {
$myprop = 'Commercial Real Estate';
} elseif ($proptype == 'Mobile Home') {
$myprop = 'Mobile Homes';
} elseif ($proptype == 'Mobile Home') {
$myprop = 'Mobile Homes';
} elseif ($proptype == 'Mobile-Homes') {
$myprop = 'Mobile Homes';
}
} else {
$myprop = 'Homes';
}
// exit;
$mlsname = 'My Florida Regional MLS DBA Stellar MLS';
$courtesy = '';
$courtesy .= 'The information relating to real estate for sale on this website comes in part from the '.$mlsname.'. This information is provided exclusively for consumers\' personal, non-commercial use. It may not be used for any purpose other than to identify prospective properties consumers may be interested in purchasing. The data is deemed reliable but is not guaranteed accurate by the MLS.';
// echo $courtesy;
$mlsname = 'Stellar MLS';
$courtesy .= '
A * means that the information is not available in the '.$mlsname.' database'."\n";
$courtesy .= '
'."\n";
if ( !isset($_REQUEST['featured']) ) {
// $headline = $mycity.' Real Estate';
$headline = $myprop.' for Sale in '.$searchcity;
if ( isset($_REQUEST['luxury']) ) {
$headline = 'Luxury Estates in the Punta Gorda Area';
} elseif (isset($_REQUEST['iswaterfront'])) {
$headline = 'Waterfront Homes in the Punta Gorda Area';
} elseif (isset($_REQUEST['gulfaccess'])) {
$headline = 'Gulf Access Homes in the Punta Gorda Area';
} elseif (isset($_REQUEST['luxcondo'])) {
$headline = 'Luxury Condos in the Punta Gorda Area';
} elseif (isset($_REQUEST['poolhome'])) {
$headline = 'Pool Homes in the Punta Gorda Area';
}
if ( isset($_GET['sold']) && $_GET['sold'] == 'sold' ) {
$headline = 'SOLD PROPERTIES REPORT
'.$headline;
}
echo ''.$headline.'
'."\n";
// start building my query
// include 'getproptype.php';
$solds = '';
$solddatewhere = '';
$soldavgprice = '';
$soldavgpricepcent = '';
if ( isset($_GET['daterange']) && isset($_GET['sold']) ) {
if ( $_GET['daterange'] == 'days30' ) {
$numdays = 30;
} elseif ( $_GET['daterange'] == 'days60' ) {
$numdays = 60;
} elseif ( $_GET['daterange'] == 'days90' ) {
$numdays = 90;
} elseif ( $_GET['daterange'] == 'months6' ) {
$numdays = 180;
}
$startdate = date('Y-m-d', strtotime("-$numdays days"));
// $startdate = '2011-07-01';
$solds = " , DATE_FORMAT( CloseDate, '%Y-%m-%d' ) AS DateSold
, CAST(ClosePrice AS DECIMAL(12,0)) AS ClosePrice
, (ClosePrice/ListPrice) * 100 AS PCent
, CONCAT(StreetName,' ',StreetSuffix,', ',City) AS Addy
";
$startdate = date('Y-m-d', strtotime("-$numdays days"));
$solddatewhere = " AND DATE_FORMAT( CloseDate,'%Y-%m-%d' ) >= '$startdate' ";
$soldavgprice = " , AVG(CAST(ClosePrice AS DECIMAL(12,0))) AS AveClosePrice ";
$soldavgpricepcent = " , ( SUM(CAST(ClosePrice AS DECIMAL(12,0))) / SUM(CAST(ListPrice AS DECIMAL(12,0))) ) * 100 AS AveTotalPCent ";
if ( $proptype == 'Lots' ) {
$solds .= ", LotSizeDimensions , WaterAccessYN ";
} elseif ( $proptype == 'Condos' ) {
$solds .= ", YearBuilt , LivingArea AS SqFtSold ";
} elseif ( $proptype == 'Commercial Property' ) {
$solds .= ", YearBuilt , BuildingAreaTotal AS SqFtSold ";
} else {
$solds .= ", YearBuilt , LivingArea AS SqFtSold ";
}
}
$saletypequery = "";
$saletype = array();
if ( isset($_GET['SaleType']) && is_array($_GET['SaleType']) ) {
if ( in_array('Private',$_GET['SaleType']) ) {
$saletype[] = " SpecialListingConditions = 'None of the Above' ";
}
if ( in_array('Foreclosure',$_GET['SaleType']) ) {
// echo '
FORECLOSURE
';
$saletype[] = " SpecialListingConditions = 'REO / Bank Owned' ";
}
if ( in_array('Shortsale',$_GET['SaleType']) ) {
$saletype[] = " SpecialListingConditions = 'Short Sale' ";
}
if ( count($_GET['SaleType']) < 3 ) {
$makesaletypearry = implode(" OR " , $saletype );
$saletypequery = " AND ( $makesaletypearry ) ";
}
}
$TheTable = 'Listings';
$myselectquery = " SELECT *
, CAST(ListPrice AS DECIMAL(12,0)) AS ListPrice
, DATE_FORMAT(ListingContractDate, '%Y') as ListYear
$solds
FROM $TheTable ";
// $leftjoinforpics = " LEFT JOIN PhotoURLs ON Listings.ListingKey = PhotoURLs.ResourceRecordKey AND DisplayOrder = 1 ";
$leftjoinforpics = " ";
$myselectquery .= $leftjoinforpics;
$mycountquery = " SELECT count(*) as HowMany $soldavgprice $soldavgpricepcent FROM $TheTable ";
// $ActiveListingTable = $TheTable.'MLSOnly';
$restofquery = " WHERE 1=1 AND MlsStatus = 'Active' ";
// must select property type here
// echo 'proptype: '.$proptype."\n";
if ( $proptype == 'Homes' ) {
$dbproptype = " AND PropertyType = 'Residential' AND PropertySubType = 'Single Family Residence' ";
}
elseif ( $proptype == 'Condos' ) {
$dbproptype = " AND PropertyType = 'Residential' AND PropertySubType IN ('Condominium','Townhouse','Villa') ";
}
elseif ( $proptype == 'Residential Income' ) {
$dbproptype = " AND PropertyType = 'Residential Income' ";
}
elseif ( $proptype == 'Lots' || $proptype == 'Land' ) {
$dbproptype = " AND PropertyType = 'Land' ";
}
elseif ( $proptype == 'Commercial' ) {
// $dbproptype = " AND PropertyType = 'Commercial' ";
$dbproptype = " AND ( PropertyType LIKE '%Commercial%' OR PropertyType LIKE '%Business%' ) ";
$proptypewhere = '';
if ( $proptype == 'Commercial' ) {
// $proptypewhere .= " AND STELLAR_ComTransactionType LIKE '%Commercial Sale%' ";
// $dbproptype .= $proptypewhere;
}
}
elseif ( $proptype == 'Income' ) {
$dbproptype = " AND PropertyType = 'Residential Income' ";
}
elseif ( $proptype == 'Rental' ) {
$dbproptype = " AND PropertyType = 'Residential Lease' ";
}
elseif ( $proptype == 'Multifamily' ) {
$dbproptype = " AND PropertyType = 'Residential Income' ";
}
elseif ( $proptype == 'Mobile-Homes' ) {
$dbproptype = " AND PropertyType = 'Residential' AND PropertySubType IN ( 'Mobile Home', 'Manufactured Home' )";
}
else {
$dbproptype = " AND PropertyType = 'Residential' ";
}
$restofquery .= " $dbproptype ";
$restofquery .= " $saletypequery AND ( `MlsStatus` = 'Active' ";
if ( isset($_GET['sold']) && $_GET['sold'] == 'sold' ) {
$restofquery = " WHERE ( 1=1 $solddatewhere $saletypequery ";
}
if ( isset($PropertySubType) && $PropertySubType != '' ) {
$restofquery .= " AND PropertySubType IN ($PropertySubType) )";
} else {
$restofquery .= " )";
}
$restofquery .= $querycitypart; // either city or county
// if not multifamily, land or commercial - check beds and baths
// if ( $_REQUEST['proptype'] != 'Multifamily' && $_REQUEST['proptype'] != 'Lots' && $_REQUEST['proptype'] != 'Commercial' ) {
$bedcheckarry = array('Residential','Homes','Mobile-Homes','Mobile','Manufactured','Manufactured/Mobile Home','Condos','Townhouse','Villa','CTV','Single Family Home','SFH','Modular');
if ( in_array($proptype , $bedcheckarry) ) {
$checkit = 'yes';
} else {
$checkit = 'no';
}
// $checkit = 'yes';
if ( $checkit == 'yes' ) {
// Bedrooms
if ( isset($_REQUEST['beds']) && !empty($_REQUEST['beds']) ) {
if ( intval($_REQUEST['beds'] == 0) ) {
$restofquery .= '';
} elseif ( intval($_REQUEST['beds'] < 4) ) {
$restofquery .= " AND BedroomsTotal >= ".intval($_REQUEST['beds'].' ');
} else {
$restofquery .= " AND BedroomsTotal >= ".intval($_REQUEST['beds'].' ');
}
if ( isset($_REQUEST['maxbeds']) && !empty($_REQUEST['maxbeds']) ) {
$restofquery .= " AND BedroomsTotal <= ".intval($_REQUEST['beds'].' ');
}
}
// Baths
if ( isset($_REQUEST['baths']) && !empty($_REQUEST['baths']) ) {
if ( intval($_REQUEST['baths'] == 0) ) {
$restofquery .= '';
} elseif ( intval($_REQUEST['baths'] < 4) ) {
$restofquery .= " AND BathroomsFull >= ".intval($_REQUEST['baths'].' ');
} else {
$restofquery .= " AND BathroomsFull >= ".intval($_REQUEST['baths'].' ');
}
}
} // END if not multifamily, land or commercial
// Min and Max price
$min = (isset($_REQUEST['min'])) ? INTVAL($_REQUEST['min']):0;
$max = (isset($_REQUEST['max'])) ? INTVAL($_REQUEST['max']):0;
if ($max != 0 && $min > $max) {
$temp = $min;
$min = $max;
$max = $temp;
}
if ( isset($_REQUEST['min']) && $_REQUEST['min'] != 0 && $min != 0 ) {
$restofquery .= " AND ListPrice >= $min ";
}
if ( isset($_REQUEST['max']) && $_REQUEST['max'] < 1000001 && $max != 0 ) {
$restofquery .= " AND ListPrice <= $max ";
}
// END Min and Max Price
// square feet min and max
// if ( isset($_REQUEST['sqftmin']) && INTVAL($_REQUEST['sqftmin']) != 0 &&
// ( $proptype == 'Homes' || $proptype = 'Condos' || $proptype == 'Commercial' || $proptype == 'Income' || $proptype == 'HomesSold' || $proptype = 'CondosSold' || $proptype == 'CommercialSold' || $proptype == 'IncomeSold' ) ) {
if ( isset($_REQUEST['sqftmin']) && INTVAL($_REQUEST['sqftmin']) != 0 && ( $_REQUEST['proptype'] != 'Vacand Land' && $_REQUEST['proptype'] != 'Land' && $_REQUEST['proptype'] != 'Lots' ) ) {
$sqftmin = INTVAL($_REQUEST['sqftmin']);
$restofquery .= " AND LivingArea >= $sqftmin AND LivingArea != '' ";
}
if ( isset($_REQUEST['sqftmax']) && INTVAL($_REQUEST['sqftmax']) != 0 && $_REQUEST['sqftmax'] != '5000+' && ( $_REQUEST['proptype'] != 'Vacand Land' && $_REQUEST['proptype'] != 'Land' && $_REQUEST['proptype'] != 'Lots' ) ) {
$sqftmax = INTVAL($_REQUEST['sqftmax']);
$restofquery .= " AND LivingArea <= $sqftmax AND LivingArea != '' ";
}
// END square feet min and max
// yearbuilt min and max
// if ( isset($_REQUEST['yearbuiltmin']) && INTVAL($_REQUEST['yearbuiltmin']) != 0 && ( $proptype != 'Vacand Land' && $proptype != 'Land' && $proptype != 'Lots' ) ) {
if ( isset($_REQUEST['yearbuiltmin']) && INTVAL($_REQUEST['yearbuiltmin']) != 0 && ( $_REQUEST['proptype'] != 'Vacand Land' && $_REQUEST['proptype'] != 'Land' && $_REQUEST['proptype'] != 'Lots' ) ) {
$yearbuiltmin = INTVAL($_REQUEST['yearbuiltmin']);
$restofquery .= " AND YearBuilt >= $yearbuiltmin AND YearBuilt != '' ";
}
if ( isset($_REQUEST['yearbuiltmax']) && INTVAL($_REQUEST['yearbuiltmax']) != 0 && ( $_REQUEST['proptype'] != 'Vacand Land' && $_REQUEST['proptype'] != 'Land' && $_REQUEST['proptype'] != 'Lots' ) ) {
$yearbuiltmax = INTVAL($_REQUEST['yearbuiltmax']);
$restofquery .= " AND YearBuilt <= $yearbuiltmax AND YearBuilt != '' ";
}
// END yearbuilt min and max
// waterfront & pool
if ( isset($_REQUEST['waterfront']) && $_REQUEST['waterfront'] == 'Y' ) {
// $restofquery .= ($waterfrontcodesarry);
// $restofquery .= " AND WaterFrontageYN = '1' ";
$restofquery .= " AND ( WaterfrontYN = 1 ) ";
} elseif ( isset($_REQUEST['waterfront']) && $_REQUEST['waterfront'] == 'N' ) {
// $restofquery .= checkarray($waterfrontcodesarry,'N');
$restofquery .= " AND WaterfrontYN != 1 ";
}
if ( isset($_REQUEST['waterfront']) && $_REQUEST['waterfront'] == 'gulfaccess') {
$_REQUEST['gulfaccess'] = 'gulfaccess';
}
if ( isset($_REQUEST['waterfront']) && $_REQUEST['waterfront'] == 'gulfaccess' ) {
// $restofquery .= " AND FeatureCodes LIKE '%X38F%' ";
$restofquery .= " AND ( WaterfrontYN = 1 AND (
STELLAR_WaterAccess LIKE '%Gulf%'
OR STELLAR_WaterAccess LIKE '%Intracoastal%'
OR STELLAR_WaterAccess LIKE '%Bay/Harbor%'
OR STELLAR_WaterAccess LIKE '%Canal - Saltwater%'
OR STELLAR_WaterAccess LIKE '%River%'
OR STELLAR_WaterAccess LIKE '%Canal - Brackish%'
) ) ";
}
if ( $checkit == 'yes' ) {
if ( isset($_REQUEST['pool']) && $_REQUEST['pool'] == 'Y' ) {
// $restofquery .= checkarray($poolcodesarry);
// $restofquery .= " AND ( ( Pool LIKE '%Private%' OR Pool LIKE '%Community%' ) ) ";
$restofquery .= " AND ( PoolPrivateYN = 1 AND PoolFeatures LIKE '%In Ground%' ) ";
// $restofquery .= " AND ( ( Pool LIKE '%Private%' OR Pool LIKE '%Community%' ) ) ";
} elseif ( isset($_REQUEST['pool']) && $_REQUEST['pool'] == 'N' ) {
// $restofquery .= checkarray($poolcodesarry,'N');
$restofquery .= " AND ( PoolPrivateYN != 1 ) ";
}
// garage
if ( isset($_REQUEST['parking']) ) {
$parking = INTVAL($_REQUEST['parking']);
if ( $parking > 0 ) {
$restofquery .= " AND GarageSpaces >= $parking ";
}
}
}
$querynolimit = " ";
$mywholecountquery = $mycountquery.$restofquery;
$result = mysqli_query($dbcmls,$mywholecountquery) or trigger_error('Bad mycount query: ' . mysqli_error($dbcmls).'
'.$mywholecountquery.'
');
if ( !$result || mysqli_num_rows($result) < 1 ) {
echo 'Sorry, no listings matched your search criteria. Please try again.
'."\n";
include 'searchform.php';
include 'footer.php';
exit;
}
$row = mysqli_fetch_assoc($result);
$mycount = $row['HowMany'];
$myavgsoldprice = '';
$myavgsoldpcent = '';
if ( isset($row['AveClosePrice']) ) {
$myavgsoldprice = $row['AveClosePrice'];
}
if ( isset($row['AveTotalPCent']) ) {
$myavgsoldpcent = $row['AveTotalPCent'];
} else {
// $myavgsoldpcent = 100;
}
$sortit = " ORDER BY ListPrice DESC ";
if ( isset($_REQUEST['orderby']) && ( $_REQUEST['orderby'] == 'ListPrice' || $_REQUEST['orderby'] == 'City' || $_REQUEST['orderby'] == 'ListingId' ) ) {
$sortit1 = " ORDER BY ".$_REQUEST['orderby'];
} else {
$sortit1 = " ORDER BY ListPrice ";
}
if ( isset($_REQUEST['sortdirection']) && ( $_REQUEST['sortdirection'] == 'ASC' || $_REQUEST['sortdirection'] == 'DESC') ) {
$sortit2 = $_REQUEST['sortdirection'];
} else {
$sortit2 = " ASC ";
}
$orderby = $sortit1.' '.$sortit2;
// $orderby = " ORDER BY ListPrice DESC ";
// PAGINATE
$limit = NUMPERPAGE; //use a default value of ten
$limitvalue = $page * $limit - ($limit);
$max_links_shown = MAXLINKS; //use default
$limitit = " LIMIT $limitvalue, ".$limit.' ';
// $fields .= " , PhotoURL ";
// $photourlsmalltable = 'PhotoURLs';
// $leftjoinforpics = " LEFT JOIN PhotoURLs ON `$table`.ListingKeyNumeric = PhotoURLsSmall.ListingKeyNumeric AND PhotoKey = 1 ";
// $myquery = " SELECT $fields FROM $dbname.`$table` $leftjoinforpics $where $proptypewhere ORDER BY $sortitby $sortitdir $limitit ";
$mywholequery = $myselectquery.$restofquery.$orderby.$limitit ;
// if ( $_SERVER['REMOTE_ADDR'] == '67.142.112.215' ) {
// echo 'myselectquery: '.$myselectquery.'
';
// echo 'restofquery: '.$restofquery.'
';
// echo 'orderby: '.$orderby.'
';
// echo 'limitit: '.$limitit.'
';
// echo 'mywholequery: '.$mywholequery.'
';
// }
$myip = 'myip';
$showqueries = 'yes';
// $showqueries = 'no';
$numofpages = ceil($mycount / $limit);
if ($limit > $mycount) {
$limit = $mycount;
}
// echoit('mycount',$mycount);
if ( $mycount > 1 ) {
$mylistings = 'listings';
$mymatch = 'match';
} elseif ($mycount == 1) {
$mylistings = 'listing';
$mymatch = 'matches';
}
if ( $mycount > 0 ) {
echo ''.number_format((float)$mycount).' '.$mylistings.'. '.ucfirst($config['myour']).' convenient search form can help you narrow down your search by modifying your search or searching only specific cities.
';
} else {
echo 'Sorry, no listings matched your search criteria. You can try another search:
';
include 'searchform.php';
include 'footer.php';
exit;
}
if ( isset($_GET['MLNums']) ) {
$mlnumarray = explode(',',$_GET['MLNums']);
$themlnums = "'".implode("', '",$mlnumarray)."'";
// $where = " WHERE ListingId IN ( $themlnums ) ";
// $table = 'Listings';
// $proptypewhere = '';
// $mywholequery = " SELECT $fields FROM $dbname.`$table` $where ORDER BY $sortitby $sortitdir ";
$mywholequery = " SELECT *, DATE_FORMAT(ListingContractDate, '%Y') as ListYear, MediaURL
WHERE ListingId IN ( $themlnums ) ";
}
if ( $_SERVER['REMOTE_ADDR'] == '172.58.174.152' ) {
echo 'mywholequery searchresults 777: '.$mywholequery."
";
}
$getlistings = mysqli_query($dbcmls,$mywholequery) or trigger_error('Bad myquery: '.mysqli_error($dbcmls).'
--'.$mywholequery);
// BEGIN STUFF FOR PAGINATION
$firststring = $_SERVER['REQUEST_URI'];
if (
$_SERVER['REQUEST_URI'] == '/waterfront-homes.html' ||
$_SERVER['REQUEST_URI'] == '/luxury-estates.html' ||
$_SERVER['REQUEST_URI'] == '/luxury-condos.html' ||
$_SERVER['REQUEST_URI'] == '/gulf-access-homes.html' ||
$_SERVER['REQUEST_URI'] == '/pool-homes.html'
) {
$firststring = '/searchresults.html?';
foreach( $_REQUEST as $key => $val ) {
// $firststring .= $key.'='.$val.'&';
$firststring .= $key.'='.$val.'&';
}
if ( $_SERVER['REQUEST_URI'] == '/waterfront-homes.html' ) {
// $firststring .= '&iswaterfront=iswaterfront';
} elseif ($_SERVER['REQUEST_URI'] == '/luxury-estates.html') {
// $firststring .= '&luxury=luxury';
} elseif ($_SERVER['REQUEST_URI'] == '/gulf-access-homes.html') {
// $firststring .= '&gulfaccess=gulfaccess';
} elseif ($_SERVER['REQUEST_URI'] == '/luxury-condos.html') {
// $firststring .= '&luxcondo=luxcondo';
} elseif ($_SERVER['REQUEST_URI'] == '/pool-homes.html') {
// $firststring .= '&poolhome=poolhome';
}
$firststring = rtrim($firststring,'&');
// echo 'this string: '.$firststring.'
';
// exit;
}
// exit;
// print '
thestring before pregreplace: '.$firststring.'
';
$thestring = $firststring;
$thestring = preg_replace('/&page=[0-9]*/','',$thestring);
$thestring = preg_replace('/&/','&',$thestring);
$thestring = preg_replace('/\+/','-',$thestring);
$thestring = rtrim($thestring,'&');
// END STUFF FOR PAGINATION
if ( !$getlistings ) {
header( "HTTP/1.0 404 Not Found" );
echo 'Sorry, no listings matched your search. Please try again...
'."\n";
include '/home/flaidx/public_html/incsbridge2022/searchform.php';
include 'footer.php';
exit;
}
if ($getlistings) {
$_SESSION['searchpage'] = $_SERVER['REQUEST_URI'];
include ('/home/flaidx/public_html/incsbridge2022/paginate.php');
if ( isset($_GET['sold']) && $_GET['sold'] == 'sold' ) {
// spititout($getlistings, $TheTable, $proptype);
include '/home/flaidx/public_html/incsbridge2022/soldtable.php';
} else {
while ($row = mysqli_fetch_assoc($getlistings)) {
include '/home/flaidx/public_html/incsbridge2022/listingtable.php';
}
}
include ('paginate.php');
} else { // END if ($getlistings)
include 'technical.php';
include 'footer.php';
exit;
}
// END if ($getlistings)
echo $courtesy;
// if ( $_SERVER['REMOTE_ADDR'] == '67.142.113.20' ) {
// $stellardate = new DateTime('2019-06-04');
// $nowdate = new DateTime();
//
// if($nowdate >= $nowdate) {
// echo 'show stellar';
// } else {
// echo 'show mfr';
// }
// }
} // END if !isset get featured
////// FEATURED LISTINGS ////// ////// Get the agents own listings
if ( isset($_REQUEST['featured']) ) {
function getspreadheader($proptype) {
$spreadheader = '';
$spreadheader .= ''."\n";
$spreadheader .= ''."\n";
$spreadheader .= '| Address | ';
$spreadheader .= 'Price | ';
if ( $proptype == 'Lots' ) {
$spreadheader .= 'Use | ';
} elseif ( $proptype == 'Commercial' ) {
$spreadheader .= 'Use | ';
} else {
$spreadheader .= 'Bedrooms | ';
$spreadheader .= 'Baths | ';
$spreadheader .= 'Sq. Ft. (Living) | ';
}
$spreadheader .= 'MLS # | ';
$spreadheader .= '
';
return $spreadheader;
}
$spreadend = '
';
if ( !empty($config['AgentID']) ) {
$agentarry = explode(',',$config['AgentID']);
if ( count($agentarry) > 1 ) {
$getagentstring = " AND ListAgentMlsId IN (".$config['AgentID'].") ";
} elseif ( count($agentarry) == 1 ) {
$getagentstring = " AND ListAgentMlsId = '".$config['AgentID']."'";
}
} else {
$getagentstring = '';
}
if ( $_SERVER['HTTP_HOST'] == 'www.portcharlottehouses.com' || $_SERVER['HTTP_HOST'] == 'www.searchsuncoast.com' ) {
$getagentstring = " AND ListOfficeMlsId = '".$config['OfficeIDNum']."'";
}
$orderby = ' ORDER BY ListPrice DESC ';
if ( $_REQUEST['featured'] == 'mobi' ) {
$orderby = ' ORDER BY StreetName ASC ';
}
$_REQUEST['proptype'] = 'Homes';
// HOMES first
$proptype = 'Homes';
$myprop = 'Home';
$myselect = " SELECT *, DATE_FORMAT(ListingContractDate, '%Y') as ListYear, PhotoURL ";
// $getfields = '';
// $getfields = $all + $homes;
// $myselect .= implode(', ',$getfields);
$fromtable = " FROM Listings ";
$andwhere = " WHERE MlsStatus = 'Active' ";
$andwhere .= " AND PropertyType = 'Residential' ";
$andwhere .= " AND PropertySubType IN ('Single Family Residence', 'Condominium', 'Townhouse', 'Villa', 'Farm', 'Manufactured Home', 'Mobile Home') ";
$andwhere .= $getagentstring;
// get pics
$table = 'Listings';
$phototable = 'PhotoURLs';
// $fields .= " , PhotoURL ";
// $leftjoinforpics = " LEFT JOIN $phototable ON `$table`.ListingKeyNumeric = $phototable.ListingKeyNumeric AND PhotoKey = 1 ";
$leftjoinforpics = " ";
$queryhomes = $myselect.$fromtable.$leftjoinforpics.$andwhere.$orderby;
// if ( $_SERVER['REMOTE_ADDR'] == '67.142.112.229' ) {
// echo 'line 918 queryhomes:
'.$queryhomes.'
';
// }
$gethomes = mysqli_query($dbcmls,$queryhomes) or trigger_error('Bad gethomes query: '.mysqli_error($dbcmls).'
'.$queryhomes);
$myselect = '';
// Condos
$proptype = 'Condos';
$myprop = 'Condo';
$myselect = " SELECT *, DATE_FORMAT(ListingContractDate, '%Y') as ListYear ";
// $getfields = '';
// $getfields = $all + $condos;
// $myselect .= implode(', ',$getfields);
$fromtable = " FROM Listings ";
$andwhere = " WHERE MlsStatus = 'Active' ";
$andwhere .= " AND PropertyType = 'Residential' ";
$andwhere .= " AND PropertySubType = 'Condominium' ";
$andwhere .= $getagentstring;
$querycondos = $myselect.$fromtable.$leftjoinforpics.$andwhere.$orderby;
// echo '
Condo query: '.$querycondos.'
';
$getcondos = mysqli_query($dbcmls,$querycondos) or trigger_error('Bad getcondos query: '.mysqli_error($dbcmls));
$myselect = '';
// Lots
$proptype = 'Lots';
$myprop = 'Lot';
$myselect = " SELECT *, DATE_FORMAT(ListingContractDate, '%Y') as ListYear ";
// $getfields = '';
// $getfields = $all + $lots;
// $myselect .= implode(', ',$getfields);
$fromtable = " FROM Listings ";
$andwhere = " WHERE MlsStatus = 'Active' ";
$andwhere .= " AND PropertyType ='Land' ";
$andwhere .= $getagentstring;
$querylots = $myselect.$fromtable.$leftjoinforpics.$andwhere.$orderby;
// echo '
Lots query: '.$querylots.'
';
$getlots = mysqli_query($dbcmls,$querylots) or trigger_error('Bad getlots query: '.mysqli_error($dbcmls));
$myselect = '';
// Commercial
$proptype = 'Commercial';
$myprop = 'Commercial Properties';
$myselect = " SELECT *, DATE_FORMAT(ListingContractDate, '%Y') as ListYear ";
// $getfields = '';
// $getfields = $all + $commercial;
// $myselect .= implode(', ',$getfields);
$fromtable = " FROM Listings ";
$andwhere = " WHERE MlsStatus = 'Active' ";
$andwhere .= " AND PropertyType ='Commercial' ";
$andwhere .= $getagentstring;
$querycommercial = $myselect.$fromtable.$leftjoinforpics.$andwhere.$orderby;
// echo '
Commercial query: '.$querycommercial.'
';
$getcommercial = mysqli_query($dbcmls,$querycommercial) or trigger_error('Bad getlots query: '.mysqli_error($dbcmls));
$myselect = '';
echo '
';
if ($gethomes && mysqli_num_rows($gethomes) > 0 ) {
$proptype = 'Homes';
echo '';
echo 'Featured Homes
';
$details = ( $_REQUEST['featured'] == 'mobi' ) ? getspreadheader($proptype) : '';
while ($row = mysqli_fetch_assoc($gethomes)) {
if ( $_REQUEST['featured'] == 'mobi' ) {
include '/home/flaidx/public_html/incsbridge2022/listingtable.php';
} else {
include '/home/flaidx/public_html/incsbridge2022/listingtable.php';
}
}
if ( $_REQUEST['featured'] == 'mobi' ) {
$details .= $spreadend;
echo $details;
}
$row = array();
}
if ($getcondos && mysqli_num_rows($getcondos) > 0 ) {
$proptype = 'Condos';
echo '';
echo 'Featured Condos
';
$details = ( $_REQUEST['featured'] == 'mobi' ) ? getspreadheader($proptype) : '';
while ($row = mysqli_fetch_assoc($getcondos)) {
if ( $_REQUEST['featured'] == 'mobi' ) {
include '/home/flaidx/public_html/incsbridge2022/listingtablespread.php';
} else {
include '/home/flaidx/public_html/incsbridge2022/listingtable.php';
}
}
if ( $_REQUEST['featured'] == 'mobi' ) {
$details .=$spreadend;
echo $details;
}
$row = array();
}
if ($getlots && mysqli_num_rows($getlots) > 0 ) {
$proptype = 'Lots';
echo '';
echo 'Featured Lots & Land
';
$details = ( $_REQUEST['featured'] == 'mobi' ) ? getspreadheader($proptype) : '';
while ($row = mysqli_fetch_assoc($getlots)) {
if ( $_REQUEST['featured'] == 'mobi' ) {
include '/home/flaidx/public_html/incsbridge2022/listingtablespread.php';
} else {
include '/home/flaidx/public_html/incsbridge2022/listingtable.php';
}
}
if ( $_REQUEST['featured'] == 'mobi' ) {
$details .=$spreadend;
echo $details;
}
$row = array();
}
if ($getcommercial && mysqli_num_rows($getcommercial) > 0 ) {
$proptype = 'Commercial';
echo'';
echo 'Featured Commercial Property
';
$details = ( $_REQUEST['featured'] == 'mobi' ) ? getspreadheader($proptype) : '';
while ($row = mysqli_fetch_assoc($getcommercial)) {
if ( $_REQUEST['featured'] == 'mobi' ) {
include '/home/flaidx/public_html/incsbridge2022/listingtablespread.php';
} else {
include '/home/flaidx/public_html/incsbridge2022/listingtable.php';
}
}
if ( $_REQUEST['featured'] == 'mobi' ) {
$details .=$spreadend;
echo $details;
}
$row = array();
}
echo $courtesy;
// echo '';
// include 'searchform.php';
}
// include '/home/flaidx/public_html/incsbridge2022/searchform.php';
include 'footer.php';