include ("navbar.php"); ?>
|
//if just entering page and no subcategory selected, display basic category description
if (!isset($subcategory)){
?>
Welcome to Minnesota Seniors
Online's Senior Living Directory
This directory was designed to assist you and your family in researching and securing housing
options appropriate for your needs or the needs of an elder relative.
To begin your search, simply click on the category that best describes
the type of housing options you are looking for:
//grab subcategories related to selected category
$subcat_query="SELECT * FROM subcategories WHERE categoryID=$categoryID OR categoryID2=$categoryID ORDER BY subcategory asc";
$subcat_result=mysql_query($subcat_query);
print "";
$i=4;
while ($subcat1 = mysql_fetch_array($subcat_result)) {
//first cell of row
if ($i % 3 == 1) {
print "";
}
print "";
if ($i % 3 == 0) {
print " ";
}
$i++;
}
print " ";
?>
Life changes happen...the kids have all grown and moved on and you just don't need the extra space anymore; physical changes may have occurred due to a medical condition where you need some assistance; or you need more than a just a little assistance...here is where you can find housing options that will fit your needs.
Our directory is easy to use. Everything has been broken out by category (ie: independent living, assisted living, skilled nursing facilities,
etc.) then by county and community. This helps to make your search fast and easy and/or find something close to your family. You'll find what you're looking for in a snap!
}
else {
//with a subcategory selected, do not display main heading or subcategory links, display subcategory heading &descrip
$subcat2_query="SELECT * FROM subcategories WHERE subcategory='$subcategory'";
$subcat2_result=mysql_query($subcat2_query);
while ($subcat2 = mysql_fetch_array($subcat2_result)) {
$subcat_display = $subcat2[subcat_display];
$subcategory_desc = $subcat2[description];
$subcategoryID = $subcat2[subcategoryID];
}
print "$subcat_display ";
if (isset($town)) {
print " > $town";
}
if (isset($let)) {
print " > \"$let\"";
}
print "";
print "$subcategory_desc ";
}
//check subcategories database to see if county or city dropdown list set to be on and also query for list of cities
if (isset($subcategory)) {
$query = "SELECT county_on, city_on FROM subcategories WHERE subcategory='$subcategory'";
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$county_on = $row['county_on'];
$city_on = $row['city_on'];
$q_cities = "SELECT * FROM clients WHERE subcategoryID=$subcategoryID AND city !='' ";
$q_cities .= "AND county1='$county' OR county2='$county' OR county3='$county' OR county4='$county' OR county5='$county' OR county6='$county' OR county7='$county' OR county8='$county' OR county9='$county' OR county10='$county' GROUP BY city ORDER BY city ASC ";
$r_cities = mysql_query($q_cities);
}
//check level2 database to see if county or city dropdown list set to be on and also query for list of cities
if (isset($level2)) {
$query = "SELECT l2_county_on, l2_city_on FROM level2 WHERE level2ID=$level2";
$result = mysql_query($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$l2_county_on = $row['county_on'];
$L2_city_on = $row['city_on'];
$q_cities = "SELECT city FROM clients WHERE level2ID = $level2 OR level2ID_2 = $level2 OR level2ID_3 = $level2 AND city != '' GROUP BY city ORDER BY city ASC";
$r_cities = mysql_query($q_cities);
}
//conditions for displaying county list
if ($county_on == 1 OR $l2_county_on == 1) {
?>
}
//conditions for displaying county list
if ( ($city_on == 1 OR $l2_city_on == 1) AND isset($county)) {
//query cities to display in dropdown
?>
}
//conditons for displaying a breakdown between Hennepin County Zones 1 & 2 -- continued conditions before client display found later on
if ( ($subcategory == 'Financial-Services' OR $subcategory == 'Heating-Cooling' OR $level2ID == '7' OR $level2ID_2 == '7' OR $level2ID_3 == '7') AND $county == 'Hennepin' ) {
print "Hennepin County To view authorized professionals servicing this area, simply click on one of the zones shown below that includes your community or the community nearest you.
Zone 1
Includes: Bloomington, Brooklyn Center, Brooklyn Park, Champlin, Crystal, Dayton, Edina, Golden Valley, Hopkins, Minneapolis, New Hope, Osseo, Plymouth, Richfield, Rogers
Zone 2
Includes: Corcoran, Eden Prairie, Excelsior, Hamel, Long Lake, Loretto, Maple Grove, Medicine Lake, Minnetonka, Minnetrista, Mound, Navarre, Robbinsdale, Rockford, St. Louis Park, Spring Park, Wayzata ";
}
else if ( $subcategory == 'Auto-Repair' AND $county == 'Hennepin' ) {
print "Hennepin County To view authorized professionals servicing this area, simply click on one of the zones shown below that includes your community or the community nearest you.
Zone 1
Includes: Bloomington, Richfield, Central Downtown, South, Southeast Or, Southwest Minneapolis, Northeast Minneapolis, Camden, Calhoun Isles, Nokomis, Lake Harriet, Longfellow, University, Phillips, Powderhorn
Zone 2
Includes: Eden Prairie, Edina, Excelsior, Hopkins, Long Lake, Minnetonka, Minnetrista, Mound, Navarre, Shorewood, St Louis Park, Spring Park, Wayzata
Zone 3
Includes: Corcoran, Eden Prairie, Edina, Excelsior, Hamel, Hopkins, Long Lake, Minnetonka, Minnetrista, Mound, Navarre, Shorewood, St Louis Park, Spring Park, Wayzata ";
}
?>
if (isset($county))
{
if ($county == 'Hennepin') {
$qualifier = "AND (county1='Hennepin County, Zone 1' OR county2='Hennepin County, Zone 1' OR county3='Hennepin County, Zone 1' OR county4='Hennepin County, Zone 1' OR county5='Hennepin County, Zone 1' OR county6='Hennepin County, Zone 1' OR county7='Hennepin County, Zone 1' OR county8='Hennepin County, Zone 1' OR county9='Hennepin County, Zone 1' OR county10='Hennepin County, Zone 1' OR
county1='Hennepin County, Zone 2' OR county2='Hennepin County, Zone 2' OR county3='Hennepin County, Zone 2' OR county4='Hennepin County, Zone 2' OR county5='Hennepin County, Zone 2' OR county6='Hennepin County, Zone 2' OR county7='Hennepin County, Zone 2' OR county8='Hennepin County, Zone 2' OR county9='Hennepin County, Zone 2' OR county10='Hennepin County, Zone 2'OR
county1='Hennepin County, Zone 3' OR county2='Hennepin County, Zone 3' OR county3='Hennepin County, Zone 3' OR county4='Hennepin County, Zone 3' OR county5='Hennepin County, Zone 3' OR county6='Hennepin County, Zone 3' OR county7='Hennepin County, Zone 3' OR county8='Hennepin County, Zone 3' OR county9='Hennepin County, Zone 3' OR county10='Hennepin County, Zone 3') ";
}
else if ($county == 'Hennepin1') {
$qualifier = "AND (county1='Hennepin County, Zone 1' OR county2='Hennepin County, Zone 1' OR county3='Hennepin County, Zone 1' OR county4='Hennepin County, Zone 1' OR county5='Hennepin County, Zone 1' OR county6='Hennepin County, Zone 1' OR county7='Hennepin County, Zone 1' OR county8='Hennepin County, Zone 1' OR county9='Hennepin County, Zone 1' OR county10='Hennepin County, Zone 1') ";
}
else if ($county == 'Hennepin2') {
$qualifier = "AND (county1='Hennepin County, Zone 2' OR county2='Hennepin County, Zone 2' OR county3='Hennepin County, Zone 2' OR county4='Hennepin County, Zone 2' OR county5='Hennepin County, Zone 2' OR county6='Hennepin County, Zone 2' OR county7='Hennepin County, Zone 2' OR county8='Hennepin County, Zone 2' OR county9='Hennepin County, Zone 2' OR county10='Hennepin County, Zone 2') ";
}
else if ($county == 'Hennepin3') {
$qualifier = "AND (county1='Hennepin County, Zone 3' OR county2='Hennepin County, Zone 3' OR county3='Hennepin County, Zone 3' OR county4='Hennepin County, Zone 3' OR county5='Hennepin County, Zone 3' OR county6='Hennepin County, Zone 3' OR county7='Hennepin County, Zone 3' OR county8='Hennepin County, Zone 3' OR county9='Hennepin County, Zone 3' OR county10='Hennepin County, Zone 3') ";
}
else if ($county == 'Ramsey') {
$qualifier = "AND (county1='Ramsey County, Zone 1' OR county2='Ramsey County, Zone 1' OR county3='Ramsey County, Zone 1' OR county4='Ramsey County, Zone 1' OR county5='Ramsey County, Zone 1' OR county6='Ramsey County, Zone 1' OR county7='Ramsey County, Zone 1' OR county8='Ramsey County, Zone 1' OR county9='Ramsey County, Zone 1' OR county10='Ramsey County, Zone 1' OR
county1='Ramsey County, Zone 2' OR county2='Ramsey County, Zone 2' OR county3='Ramsey County, Zone 2' OR county4='Ramsey County, Zone 2' OR county5='Ramsey County, Zone 2' OR county6='Ramsey County, Zone 2' OR county7='Ramsey County, Zone 2' OR county8='Ramsey County, Zone 2' OR county9='Ramsey County, Zone 2' OR county10='Ramsey County, Zone 2') ";
}
else {
$qualifier = "AND (county1='$county' OR county2='$county' OR county3='$county' OR county4='$county' OR county5='$county' OR county6='$county' OR county7='$county' OR county8='$county' OR county9='$county' OR county10='$county') ";
}
}
if (isset($city))
{
$qualifier .= " AND city='$city'";
}
if (isset($level2))
{
$qualifier .= " AND (level2ID=$level2ID OR level2ID_2=$level2ID OR level2ID_3=$level2ID)";
}
//this query selects clients from appropriate category
$listing_query="SELECT * FROM clients WHERE categoryID=$categoryID AND subcategoryID=$subcategoryID $qualifier ORDER BY featured desc, list_order ";
$listing_result=mysql_query($listing_query);
@$count = mysql_num_rows($listing_result);
//echo "count = $count";
//-----------------------FUNCTIONS AND CODE FOR SHUFFLING LISTINGS AND UPDATING DATABASE -----------------------------------------
//creates a 2d array from a mysql result
function mysql_2d_array ( $result) {
$i=0;
$ret = array();
while ($row = mysql_fetch_assoc($result)) {
foreach ($row as $key => $value) {
$ret[$i][$key] = $value;
}
$i++;
}
return ($ret);
}
//shuffle client array in linear fashion, featured listings stay on top
function client_shuffle ($array, $array_count) {
$i=0;
while ($i < $array_count) {
if ($i == 0 AND $array[0]['featured'] == 1) {
$new_arr[$i] = $array[$i];
$new_arr[$i]['list_order'] = $i;
$i++;
}
else if ($i == 0 AND $array[0]['featured'] == 0) {
$new_arr[($array_count - 1)] = $array[$i];
$new_arr[($array_count - 1)]['list_order'] = ($array_count - 1);
$i++;
}
else if ($i == 1 AND $array[0]['featured'] == 1) {
$new_arr[($array_count - 1)] = $array[$i];
$new_arr[($array_count - 1)]['list_order'] = ($array_count - 1);
$i++;
}
else if ($i == 1 AND $array[0]['featured'] == 0) {
$new_arr[$i - 1] = $array[$i];
$new_arr[$i - 1]['list_order'] = ($i - 1);
$i++;
}
else if ($i > 1 ) {
$new_arr[$i - 1] = $array[$i];
$new_arr[$i - 1]['list_order'] = ($i - 1);
$i++;
}
}
return $new_arr;
}
@$unshuffled_listing = mysql_2d_array($listing_result);
//print_r($unshuffled_listing);
$listing = client_shuffle($unshuffled_listing, $count);
//print "";
//print_r($listing);
//update database with new order
for ($row = 0; $row < $count; $row++) {
$order = $listing[$row]['list_order'];
$client_id = $listing[$row]['clientID'];
$query="UPDATE clients SET list_order=$order WHERE clientID=$client_id";
mysql_query($query);
//echo $query;
}
/* --------------------------old random shuffle stuff -------------------------------------------
//shuffles a 2d array reording key numbers
function array_shuffle ($array, $shuf) {
$i=0;
$z = $shuf;
while (count($array) > 0) {
if ($z == 0) {
$new_arr[0] = $array[0];
unset($array[0]);
$z = 1;
}
else {
$val = array_rand($array);
$new_arr[$i] = $array[$val];
unset($array[$val]);
}
$i++;
}
return $new_arr;
}
//test to see if there is a listing designated as FEATURED
if ($normal_listing[0]['featured'] == 1) {
$shuffle = 0;
}
else {
$shuffle = 1;
}
$shuffled_listing = array_shuffle($normal_listing, $shuffle);
$listing = $shuffled_listing;
if ($shuffle == 1) {
$listing = $shuffled_listing;
}
else {
$listing = $normal_listing;
}
*/
//--------------------------- END SETUP OF SHUFFLED LISTING AND DATABASE UPDATE---------------------------------------------------
if ( $county_on == 1 AND !isset($county)) {} //subcategories that have county breakdown on, but no county picked yet, don't display listings
else if ( $city_on == 1 AND !isset($city)) {} //subcategories that have city breakdown on, but no county picked yet, don't display listings
else if ( $l2_county_on == 1 AND !isset($county)) {} //level2 that have county breakdown on, but no city picked yet, don't display listings
else if ( $l2_city_on == 1 AND !isset($city)) {} //level2 that have city breakdown on, but no city picked yet, don't display listings
else if ( $subcategory == 'Financial-Services' AND $county == 'Hennepin') {} //don't show listings, allow county sub-division to display
else if ( $subcategory == 'Heating-Cooling' AND $county == 'Hennepin') {} //don't show listings, allow county sub-division to display
else if ( $subcategory == 'Auto-Repair' AND $county == 'Hennepin') {} //don't show listings, allow county sub-division to display
else if ( ($level2ID == '7' OR $level2ID_2 == '7' OR $level2ID_3 == '7') AND $county == 'Hennepin') {} //don't show listings, allow county division to display
else if ($count == 0 AND isset($subcategory)) {
print "To promote your company here, please call (763) 780-8997 for listing information. | ";
}
else if ( (isset($subcategory) AND $level2_check == 0) OR isset($level2) ) {
$i=0;
for ($row = 0; $row < $count; $row++) {
if ($i == 0) {print "
| ";}
print "";
if ($listing[$row]['clientID'] == 698) {
include ('home_instead.php');
}
else {
print "";
}
else {
print "class='listing_box'>";
}
if ($listing[$row]['link'] != '') {
$url = absolute_url($listing[$row]['link']);
print "".$listing[$row]['company']."";
}
else {
print "".$listing[$row]['company']."";
}
print " ".$listing[$row]['description']." ";
if ($listing[$row]['address'] != '') {
print "Address: ".$listing[$row]['address'].", ";
if ($listing[$row]['suite'] != '') {print "Ste ".$listing[$row]['suite'].", ";}
print "".$listing[$row][city].", ".$listing[$row]['state']." ".$listing[$row]['zip']." ";
}
print "Tel: ".$listing[$row]['phone_listing']; if ($listing[$row]['ext_listing'] != ''){print " x".$listing[$row]['ext_listing'];} print " ";
if ($listing[$row]['phone_listing2'] != '') {
print "Tel: ".$listing[$row]['phone_listing2']." ";
}
if ($listing[$row]['fax'] != '') {
print "Fax: ".$listing[$row]['fax']." ";
}
if ($listing[$row]['email_listing'] != '') {
print "Email: ".$listing[$row]['email_listing']." ";
}
if ($listing[$row]['link'] != '' ) {
$url = absolute_url($listing[$row]['link']);
print "Website: $url ";
}
if ($listing[$row]['address'] != '' AND $listing[$row]['map'] !=0) {
print "Directions:
Click Here";
}
if ($listing[$row]['county1'] !='') {
print " County(s) Served: ";
if ($listing[$row]['county1'] !='') { echo $listing[$row]['county1']; }
for ($x = 2; $x < 11; $x++) {
if ($listing[$row]['county'.$x] !='') {
print ", ";
echo $listing[$row]['county'.$x];
}
}
}
print " ";
if ($listing[$row]['ad'] != '') {
//get coupon dimensions
$coupon = "ads/".$listing[$row]['ad'].".jpg";
$size = getimagesize($coupon);
$width = $size[0]+20;
$height = $size[1]+70;
print "Coupon: Click to view";
}
print " | ";
print " | ";
print " ";
print "
| ";
}
$i++;
}
}
?>
|