function FamilyInfoByDistance($iFamily) { // Handle the degenerate case of no family selected by just making the array without // distance and bearing data, and don't bother to sort it. if ($iFamily) { // Get info for the selected family $sSQL = "SELECT fam_ID as selected_fam_ID, fam_Name as selected_fam_Name, fam_Address1 as selected_fam_Address1, fam_City as selected_fam_City, fam_State as selected_fam_State, fam_Zip as selected_fam_Zip, fam_Latitude as selected_fam_Latitude, fam_Longitude as selected_fam_Longitude from family_fam WHERE fam_ID=" . $iFamily; $rsFamilies = RunQuery($sSQL); extract(mysql_fetch_array($rsFamilies)); } // Compute distance and bearing from the selected family to all other families $sSQL = "SELECT fam_ID, fam_Name, fam_Address1, fam_City, fam_State, fam_Zip, fam_Latitude, fam_Longitude from family_fam"; $rsFamilies = RunQuery($sSQL); while ($aFam = mysql_fetch_array($rsFamilies)) { extract($aFam); if ($iFamily) { $results[$fam_ID]["Distance"] = floatval(LatLonDistance($selected_fam_Latitude, $selected_fam_Longitude, $fam_Latitude, $fam_Longitude)); $results[$fam_ID]["Bearing"] = LatLonBearing($selected_fam_Latitude, $selected_fam_Longitude, $fam_Latitude, $fam_Longitude); } $results[$fam_ID]["fam_Name"] = $fam_Name; $results[$fam_ID]["fam_Address1"] = $fam_Address1; $results[$fam_ID]["fam_City"] = $fam_City; $results[$fam_ID]["fam_State"] = $fam_State; $results[$fam_ID]["fam_Zip"] = $fam_Zip; $results[$fam_ID]["fam_Latitude"] = $fam_Latitude; $results[$fam_ID]["fam_Longitude"] = $fam_Longitude; $results[$fam_ID]["fam_ID"] = $fam_ID; } if ($iFamily) { $resultsByDistance = SortByDistance($results); } else { $resultsByDistance = $results; } return $resultsByDistance; }
} if ($fam_City != "") { echo $fam_City . ", "; } if ($fam_State != "") { echo $fam_State; } if ($fam_Zip != "") { echo " " . $fam_Zip; } if ($fam_Country != "") { echo "<br>" . $fam_Country . "<br>"; } if ($fam_Latitude && $fam_Longitude) { if ($nChurchLatitude && $nChurchLongitude) { $sDistance = LatLonDistance($nChurchLatitude, $nChurchLongitude, $fam_Latitude, $fam_Longitude); $sDirection = LatLonBearing($nChurchLatitude, $nChurchLongitude, $fam_Latitude, $fam_Longitude); echo $sDistance . " " . strtolower($sDistanceUnit) . " " . $sDirection . " of church<br>"; } } echo "</font></div>"; //Show links to mapquest, US Post Office, and Geocoder US $bShowUSLinks = false; $bShowMQLink = false; if ($fam_Address1 != "" && $fam_City != "" && $fam_State != "") { if ($fam_Country == "United States") { $sMQcountry = ""; $bShowUSLinks = true; } elseif ($fam_Country == "Canada") { $sMQcountry = "country=CA&"; $bShowMQLink = true;