dbconnect(); // for pagination we need cur listings, per page, sorting $listings->perpage = ( isset($_REQUEST['perpage']) && $_REQUEST['perpage'] != '' ? $_REQUEST['perpage'] : 10 ); $listings->curpage = ( isset($_REQUEST['curpage'] ) && $_REQUEST['curpage'] != '' ? $_REQUEST['curpage'] : 1 ); $listings->sortorder = ( isset( $_REQUEST['sortorder'] ) && $_REQUEST['sortorder'] != '' ? $_REQUEST['sortorder'] : "ASC" ); $listings->url = "/foreclosure-search.html"; $listings->s_city = ( isset( $_REQUEST['city'] ) && $_REQUEST['city'] != '' ? $_REQUEST['city'] : "ASC" ); $listings->s_minprice = ( isset( $_REQUEST['minprice'] ) && $_REQUEST['minprice'] != '' ? $_REQUEST['minprice'] : "" ); $listings->s_maxprice = ( isset( $_REQUEST['maxprice'] ) && $_REQUEST['maxprice'] != '' ? $_REQUEST['maxprice'] : "" ); $listings->s_bedrooms = ( isset( $_REQUEST['bedrooms'] ) && $_REQUEST['bedrooms'] != '' ? $_REQUEST['bedrooms'] : "" ); $listings->s_bathrooms = ( isset( $_REQUEST['bathrooms'] ) && $_REQUEST['bathrooms'] != '' ? $_REQUEST['bathrooms'] : "" ); $listings->s_mls = ( isset( $_REQUEST['mls'] ) && $_REQUEST['mls'] != '' ? $_REQUEST['mls'] : "" ); $listings->s_address = ( isset( $_REQUEST['address'] ) && $_REQUEST['address'] != '' ? $_REQUEST['address'] : "" ); $listings->ptitle = "Homes Near ". ucwords(strtolower($_GET['city'])).", Michigan"; // also .htaccess must allow php within .html files to work properly $_cityzip = (isset($_GET['city']) ? $_GET['city'] : ''); $_bedrooms = (isset($_GET['bedrooms']) ? $_GET['bedrooms'] : ''); $_bathrooms = (isset($_GET['bathrooms']) ? $_GET['bathrooms'] : ''); $_minprice = (isset($_GET['minprice']) ? $_GET['minprice'] : ''); $_maxprice = (isset($_GET['maxprice']) ? $_GET['maxprice'] : ''); $_mls = (isset($_GET['mls']) ? $_GET['mls'] : ''); $_address = (isset($_GET['address']) ? $_GET['address'] : ''); $qd = 0; $q = ""; // original query //$q = "select * from listings where "; // new query to limit results to foreclosures $q = "select * from listings where OWNERSHIP = 'B' AND "; if( $_cityzip != '' ){ $q .= "School_District LIKE '%$_cityzip%' "; $qd++; } if( $_minprice != '' ){ // append AND to query if school included if( $qd > 0 ){ $q .= " AND "; } if( $_maxprice != '' ){ $q .= " ( ListPrice BETWEEN '$_minprice' AND '$_maxprice' ) "; $qd++; } else { $q .= " ListPrice > '$_minprice' "; $qd++; } } else { if( $_maxprice != '' ){ $q .= " ListPrice < '$_maxprice' "; $qd++; } } if( $_bedrooms != '' ){ if( $qd > 0 ){ $q .= " AND "; } $q .= "No_Bedrooms = '$_bedrooms' "; $qd++; } if( $_bathrooms != '' ){ if( $qd > 0 ){ $q .= " AND "; } $q .= "Tot_Baths = '$_bathrooms' "; $qd++; } if( $_mls != '' ){ if( $qd > 0 ){ $q .= " AND "; } $q = "select * from listings where MLSNUMBER = '$_mls' "; $qd++; } if( $_address != '' ){ if( $qd > 0 ){ $q .= " AND "; } $parts = explode(" ",$_address); $q = "select * from listings where STREETNUMBER LIKE '%$parts[0]%' AND STREETNAME LIKE '%$parts[1]%' "; $qd++; } $limits = " limit " . ( ($listings->curpage - 1) * $listings->perpage ) . ", " . $listings->perpage; $var_ql = mysql_query ("$q AND STATUS != 'OMKT' ORDER BY LISTPRICE DESC "); $var_ql_limit = mysql_query ("$q AND STATUS != 'OMKT' ORDER BY LISTPRICE DESC $limits"); // also .htaccess must allow php within .html files to work properly ?> <?php echo $p_title;?>

Foreclosure Search

Search a complete list of foreclosed homes for sale in Livingston County and throughout Michigan in cities such as Brighton MI, Pinckney, and Howell MI. Narrow down your search by area, number of bedrooms, bathrooms, price, or style of home and contact a foreclosure agent at (810) 626-5600 for more information.

Search by City/Twp

Optional Information:

Address

MLS #

Choose Additional Options

to with and
paginate($var_ql); $listings->displayhomes($var_ql_limit); echo "
\n"; $listings->paginate($var_ql); } ?>