United Realty Center Online: Listings
if (isset($by_agent)) {
/*******************************************************************
* The By Agent variable indicates the drop down on the agents.php was
* used or the link within the short agent info fieldsets was clicked.
* Show their contact information and all their listings.
********************************************************************/
// CHECK TO SEE IF THE FORM WAS USED OR NOT
if ($by_agent=="FORM") {
$agentid = $_POST['agentid'];
} else {
$agentid = $by_agent;
}
include 'db.php';
// GATHER THE NECESSARY INFO FOR THE AGENT FROM THE AGENTS TABLE
$sql_agent = mysql_query("SELECT * FROM agents WHERE agentid='$agentid'");
$row_agent = mysql_fetch_object($sql_agent);
$agentid = $row_agent->agentid;
$first_name = $row_agent->first_name;
$last_name = $row_agent->last_name;
$mobile_number = $row_agent->mobile_number;
$fax_number = $row_agent->fax_number;
$office_number = $row_agent->office_number;
$agent_email_address = $row_agent->email_address;
$pic_on_file = $row_agent->pic_on_file;
print "
";
// GATHER THE AGENTS LISTINGS
$sql = mysql_query("SELECT * FROM office_listings WHERE listing_agent='$agentid' ORDER BY listing_price");
$total_rows = mysql_result(mysql_query("SELECT COUNT(mls_number) FROM office_listings WHERE listing_agent='$agentid'"),0);
/************************************************
* use a fieldset for each individual listing
* with a table within the fieldset for structure
************************************************/
print "
Results Found: $total_rows total listings
";
$i = 1;
$color1 = "#990000";
$color2 = "#333399";
$row_count = 0;
while ($row = mysql_fetch_object($sql)) {
$row_color = ($row_count % 2) ? $color1 : $color2;
$mls_number = $row->mls_number;
$mls_number = strtoupper($mls_number);
$image_file = $mls_number."_000.jpg";
$main_image = "";
$map_address = strtoupper(str_replace(" ","+",$row->street_address));
$map_city = strtoupper(str_replace(" ","+",$row->city));
$title="$row->listing_title";
$open_house = $row->open_house;
$listing_images = $row->listing_images;
// IF NO IMAGES, SHOW THE PICTURES COMING SOON IMAGE
if ($listing_images==0) {
$main_image = "";
}
// IF THE PROPERTY IS SOLD SHOW THE SOLD IMAGE SPASH, OTHER SHOW ALL DETAILS
if ($row->status=="SOLD") {
$description = "
";
} else {
$description = $row->description;
// PUT A MAX CHARACTERS ON THE DESCRIPTION SO IT WILL FIT PROPERLY
$max_count = 210;
$str_to_count = html_entity_decode($description);
if (strlen($str_to_count) <= $max_count) {
$description = $description;
} else {
$description = substr($str_to_count, 0, $max_count - 3);
$description .= "...";
$description = htmlentities($description);
}
$description = strtoupper($description);
}
if ($open_house <> "") {
$new_table = "
Bedrooms: $row->bedrooms
Bathrooms: $row->bathrooms
Square Ft: $row->build_area
Year Built: $row->year_built
";
}
// FORMAT THE PRICE
$listing_price = $row->listing_price;
$listing_price = number_format($listing_price);
print "
";
$row_count++;
$i++;
}
print "
Results Found: $total_rows total listings
";
} elseif (isset($search)) {
/*************************************************************************************
* The search variable indicates a search has been conducted and now run a series of
* criteria scripts to see how the listings will be queried. If no matches, display a
* notice to the user, otherwise show all matches
*************************************************************************************/
$search = @$_POST['search'];
$criteria = "";
$c_count = 0;
$zipcode = @$_POST['zipcode'];
if ($zipcode=="") {
$criteria .= "";
} else {
$zipcode = $zipcode{0}.$zipcode{1}.$zipcode{2}.$zipcode{3};
$criteria .= "zip_code LIKE '$zipcode%'";
$c_count++;
}
$city = @$_POST['city'];
if ($city=="") {
$criteria .= "";
} else {
if ($c_count>0) {
$criteria .= " AND ";
}
$criteria .= "city = '$city'";
$c_count++;
}
$price_low = @$_POST['price_low'];
$price_low = stripslashes($price_low);
$price_low = str_replace(",","",$price_low);
$price_low = str_replace("$","",$price_low);
if ($price_low==0) {
$criteria .= "";
} else {
if ($c_count>0) {$criteria .= " AND ";}
$criteria .= "listing_price >= '$price_low'";
$c_count++;
}
$price_high = @$_POST['price_high'];
$price_high = stripslashes($price_high);
$price_high = str_replace(",","",$price_high);
$price_high = str_replace("$","",$price_high);
if ($price_high>950000) {
$criteria .= "";
} else {
if ($c_count>0) {$criteria .= " AND ";}
$criteria .= "listing_price <= '$price_high'";
$c_count++;
}
// MYSQL QUERY USING THE CRITERIA FROM SEARCH OPTION
include 'db.php';
$sql = mysql_query("SELECT * FROM office_listings WHERE $criteria ORDER BY listing_price");
$total_rows = mysql_result(mysql_query("SELECT COUNT(mls_number) FROM office_listings WHERE $criteria"),0);
/************************************************
* use a fieldset for each individual listing
* with a table within the fieldset for structure
************************************************/
print "
Results Found: $total_rows total listings
";
$i = 1;
$color1 = "#990000";
$color2 = "#333399";
$row_count = 0;
while ($row = mysql_fetch_object($sql)) {
$row_color = ($row_count % 2) ? $color1 : $color2;
$mls_number = $row->mls_number;
$mls_number = strtoupper($mls_number);
$image_file = $mls_number."_000.jpg";
$main_image = "";
$map_address = strtoupper(str_replace(" ","+",$row->street_address));
$map_city = strtoupper(str_replace(" ","+",$row->city));
$title="$row->listing_title";
$open_house = $row->open_house;
$listing_images = $row->listing_images;
// IF NO IMAGES, SHOW THE PICTURES COMING SOON IMAGE
if ($listing_images==0) {
$main_image = "";
}
// IF THE PROPERTY IS SOLD SHOW THE SOLD IMAGE SPASH, OTHER SHOW ALL DETAILS
if ($row->status=="SOLD") {
$description = "
";
} else {
$description = $row->description;
// PUT A MAX CHARACTERS ON THE DESCRIPTION SO IT WILL FIT PROPERLY
$max_count = 210;
$str_to_count = html_entity_decode($description);
if (strlen($str_to_count) <= $max_count) {
$description = $description;
} else {
$description = substr($str_to_count, 0, $max_count - 3);
$description .= "...";
$description = htmlentities($description);
}
$description = strtoupper($description);
}
if ($open_house <> "") {
$new_table = "
Bedrooms: $row->bedrooms
Bathrooms: $row->bathrooms
Square Ft: $row->build_area
Year Built: $row->year_built
";
}
// FORMAT THE PRICE
$listing_price = $row->listing_price;
$listing_price = number_format($listing_price);
print "
";
$row_count++;
$i++;
}
print "
Results Found: $total_rows total listings
";
} else { // NO SEARCH CONDUCTED
/**************************************************************************************
* Create a script to count how many total listing are in the office listings table and
* separate the viewable results in groups of seven, with next and previous links using
* a url variable (ref) to determine to start count of each and the start query for the
* mysql query. Each mysql query will have a limit of 7.
**************************************************************************************/
include 'db.php';
$total_rows = mysql_result(mysql_query("SELECT COUNT(mls_number) FROM office_listings"),0);
$total_pages = $total_rows / 7;
if ((@$ref < 7) || (!$ref)) {
$start = 0;
} else {
$start = $ref;
}
$page_links = "";
if ($start > 0) {
$previous_ref = $start - 7;
$page_links = "Previous";
$next_ref = $start + 7;
if ($next_ref < $total_rows) {
$page_links .= " || Next";
}
} else {
$next_ref = $start + 7;
$page_links .= "Next";
}
/*****************************************
* run query according to previous results
*****************************************/
$sql = mysql_query("SELECT * FROM office_listings ORDER BY listing_price LIMIT $start, 7");
/************************************************
* use a fieldset for each individual listing
* with a table within the fieldset for structure
************************************************/
print "
$total_rows total listings | $page_links
";
$i = 1;
$color1 = "#990000";
$color2 = "#333399";
$row_count = 0;
while ($row = mysql_fetch_object($sql)) {
$row_color = ($row_count % 2) ? $color1 : $color2;
$mls_number = $row->mls_number;
$mls_number = strtoupper($mls_number);
$image_file = $mls_number."_000.jpg";
$main_image = "";
$map_address = strtoupper(str_replace(" ","+",$row->street_address));
$map_city = strtoupper(str_replace(" ","+",$row->city));
$title="$row->listing_title";
$open_house = $row->open_house;
$listing_images = $row->listing_images;
// IF NO IMAGES, SHOW THE PICTURES COMING SOON IMAGE
if ($listing_images==0) {
$main_image = "";
}
// IF THE PROPERTY IS SOLD SHOW THE SOLD IMAGE SPASH, OTHER SHOW ALL DETAILS
if ($row->status=="SOLD") {
$description = "
";
} else {
$description = $row->description;
// PUT A MAX CHARACTERS ON THE DESCRIPTION SO IT WILL FIT PROPERLY
$max_count = 210;
$str_to_count = html_entity_decode($description);
if (strlen($str_to_count) <= $max_count) {
$description = $description;
} else {
$description = substr($str_to_count, 0, $max_count - 3);
$description .= "...";
$description = htmlentities($description);
}
$description = strtoupper($description);
}
if ($open_house <> "") {
$new_table = "