|
Media
|
Type
|
Price
|
Address
|
Size
|
Beds
|
Baths
|
IDX
|
The idx server is being updated by idx!");
mssql_select_db("idx");
//////////////////////////////////////////////////////////////////
// Search function for first search form /
// /
// /
// /
//////////////////////////////////////////////////////////////////
if(!empty($recent)){
$recentins="Select TOP 10 *";
$sort="recent";
} else{
$recentins="SELECT *";
}
switch($PropertyType){
case "Residential":
$PropertyType="and col005 = 'R'";
break;
case "Commercial":
$PropertyType="and col005 = '5' or col005 = '6'";
break;
case "Land":
$PropertyType="and col005 = '4'";
break;
case "ALL":
$PropertyType="";
break;
}
if($decode != "1"){
if(!empty($internaldb)){
if(!empty($Address)){
if($done==""){
$result = mssql_query("SELECT * from idxlistings where Col034 like '%$Address%' and col002 = 'Re/Max Alliance, REALTORS' $PropertyType order by col004 desc");
$done="1";
$r1=base64_encode("SELECT * from idxlistings where Col034 like '%$Address%' and col002 = 'Re/Max Alliance, REALTORS' $PropertyType order by col004 desc");
} else {
$result = mssql_query("SELECT * from idxlistings where col002 = 'Re/Max Alliance, REALTORS' $PropertyType order by col004");
$r1=base64_encode("SELECT * from idxlistings where col002 = 'Re/Max Alliance, REALTORS' $PropertyType order by col004");
}
}
if(!empty($MLS)){
if($done==""){
$done="1";
$result = mssql_query("SELECT * from idxlistings where Col001 = '$MLS' $PropertyType and col002 = 'Re/Max Alliance, REALTORS' $PropertyType order by col004 desc");
$r1=base64_encode("SELECT * from idxlistings where Col001 = '$MLS' $PropertyType and col002 = 'Re/Max Alliance, REALTORS' $PropertyType order by col004 desc");
}
}
if(!empty($submit)){
if($done==""){
switch ($Sort) {
case "DPrice":
$sortby="col004";
$sortdirection="DESC";
break;
case "APrice":
$sortby="col004";
$sortdirection="ASC";
break;
case "DSize":
$sortby="col016";
$sortdirection="DSC";
break;
case "ASize":
$sortby="col016";
$sortdirection="ASC";
break;
case "recent":
$sortby="col001";
$sortdirection="ASC";
break;
}
if(!empty($Location)){
$t=explode(',', $Location);
if(!empty($t[1])){
$area = "col006 IN ('";
$area.= $t[0];
$area.= "' ";
$area.= ",'";
$area.= $t[1];
$area.= "'";
if(!empty($t[2])) {
$area.= ",'";
$area.= $t[2];
$area.= "'";
}
if(!empty($t[3])) {
$area.= ",'";
$area.= $t[3];
$area.= "'";
}
if(!empty($t[4])) {
$area.= ",'";
$area.= $t[4];
$area.= "'";
}
if(!empty($t[5])) {
$area.= ",'";
$area.= $t[5];
$area.= "'";
}
$area.= ") and";
} else {
$area = "col006 = '";
$area.= $t[0];
$area.= "' and";
}
}
$HighPrice=number_format($HighPrice);
$HighPrice=str_replace(",","",$HighPrice);
$LowPrice=number_format($LowPrice);
$LowPrice=str_replace(",","",$LowPrice);
if(!empty($BedRooms)){
$bedins= "and Col013 >= '$BedRooms'";
}
if(!empty($Baths)){
$bathins= "and Col014 >= '$Baths'";
}
if(!empty($SquareFeet)){
$squareftins= "and Col016 >= $SquareFeet";
}
if(!empty($Acreage)){
$acreageins= "and Col019 >= '$Acreage'";
}
if(!empty($recent)){
$recentins= "SELECT TOP 10 *";
$Sort="recent";
} else {
$recentins= "SELECT *";
}
//print($area);
if(!empty($LowPrice)){
if(!empty($HighPrice)){
$LowPrice=$LowPrice."000";
$HighPrice=$HighPrice."000";
$result = mssql_query("SELECT * from idxlistings where $area Col004 between '$LowPrice' and '$HighPrice' and col002 = 'Re/Max Alliance, REALTORS' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
$r1=base64_encode("SELECT * from idxlistings where $area Col004 between '$LowPrice' and '$HighPrice' and col002 = 'Re/Max Alliance, REALTORS' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
} else {
$result = mssql_query("SELECT * from idxlistings where $area Col004 >= '$LowPrice' and col002 = 'Re/Max Alliance, REALTORS' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
$r1=base64_encode("SELECT * from idxlistings where $area Col004 >= '$LowPrice' and col002 = 'Re/Max Alliance, REALTORS' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
}
} else {
$result = mssql_query("SELECT * from idxlistings where $area col002 = 'Re/Max Alliance, REALTORS' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
$r1=base64_encode("SELECT * from idxlistings where $area col002 = 'Re/Max Alliance, REALTORS' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
}
}
}
} else {
if(!empty($Address)){
if($done==""){
$result = mssql_query("SELECT * from idxlistings where Col034 like '%$Address%' order by col004 desc");
$done="1";
$r1=base64_encode("SELECT * from idxlistings where Col034 like '%$Address%' order by col004 desc");
} else {
$result = mssql_query("SELECT * from idxlistings where order by col004");
$r1=base64_encode("SELECT * from idxlistings where order by col004");
}
}
if(!empty($MLS)){
if($done==""){
$done="1";
$result = mssql_query("SELECT * from idxlistings where Col001 = '$MLS' order by col004 desc");
$r1=base64_encode("SELECT * from idxlistings where Col001 = '$MLS' order by col004 desc");
}
}
if(!empty($submit)){
if($done==""){
switch ($Sort) {
case "DPrice":
$sortby="col004";
$sortdirection="DESC";
break;
case "APrice":
$sortby="col004";
$sortdirection="ASC";
break;
case "DSize":
$sortby="col016";
$sortdirection="DSC";
break;
case "ASize":
$sortby="col016";
$sortdirection="ASC";
break;
case "recent":
$sortby="col001";
$sortdirection="ASC";
break;
}
if(!empty($Location)){
$t=explode(',', $Location);
if(!empty($t[1])){
$area = "col006 IN ('";
$area.= $t[0];
$area.= "' ";
$area.= ",'";
$area.= $t[1];
$area.= "'";
if(!empty($t[2])) {
$area.= ",'";
$area.= $t[2];
$area.= "'";
}
if(!empty($t[3])) {
$area.= ",'";
$area.= $t[3];
$area.= "'";
}
if(!empty($t[4])) {
$area.= ",'";
$area.= $t[4];
$area.= "'";
}
if(!empty($t[5])) {
$area.= ",'";
$area.= $t[5];
$area.= "'";
}
$area.= ") and";
} else {
$area = "col006 = '";
$area.= $t[0];
$area.= "' and";
}
}
$HighPrice=number_format($HighPrice);
$HighPrice=str_replace(",","",$HighPrice);
$LowPrice=number_format($LowPrice);
$LowPrice=str_replace(",","",$LowPrice);
if(!empty($BedRooms)){
$bedins= "and Col013 >= '$BedRooms'";
}
if(!empty($Baths)){
$bathins= "and Col014 >= '$Baths'";
}
if(!empty($SquareFeet)){
$squareftins= "and Col016 >= $SquareFeet";
}
if(!empty($Acreage)){
$acreageins= "and Col019 >= '$Acerage'";
}
if(!empty($recent)){
$recentins= "SELECT TOP 10 *";
$Sort="recent";
} else {
$recentins= "SELECT *";
}
//print($area);
if(!empty($LowPrice)){
if(!empty($HighPrice)){
$LowPrice=$LowPrice."000";
$HighPrice=$HighPrice."000";
$result = mssql_query("$recentins from idxlistings where $area Col004 between '$LowPrice' and '$HighPrice' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
$r1=base64_encode("$recentins from idxlistings where $area Col004 between '$LowPrice' and '$HighPrice' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
} else {
$result = mssql_query("$recentins from idxlistings where $area Col004 >= '$LowPrice' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
$r1=base64_encode("$recentins from idxlistings where $area Col004 >= '$LowPrice' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
}
} else {
$result = mssql_query("$recentins from idxlistings where $area col002 !='' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
$r1=base64_encode("$recentins from idxlistings where $area col002 !='' $bedins $bathins $squareftins $acreageins $PropertyType order by $sortby $sortdirection");
}
}
}
//end of internal db else
}
} else {
$r2=base64_decode($r1);
//$current_count=$page*15;
}
if(!empty($r1)){
$r2=base64_decode($r1);
$result = mssql_query($r2);
}
// return 10 at a time
$max_recs = "16";
// already got 5 records
@mssql_data_seek($result, $current_count);
$num="0";
while ($buffer = mssql_fetch_array($result)) {
$num++;
if($num== $max_recs){
$testnum=$current_count+"16";
$current_count=$testnum;
?>
|