I have a buddypress installation that I am using locations in the profile. I need the search results to display the distance between the zip code searched for (I have a database with all zipcodes) and the latitude and longitude of the matching search results. I have a script that calculates the distance between longitude and latitude coordinants and it works when I use sample data, but need help pulling in the zipcode and lon and lat from the search and assigning the long and lat from the profile I have this NEARLY DONE but need help finishing. Then I need the page to SORT ACCORDING TO THE CLOSEST SEARCH RESULT and paginate the remaining results.
I am looking for someone to do this in the next couple hours, please do not respond if you can't work on it right away and if you can't talk on SKYPE.
require_once("[url removed, login to view]");
// Lookup the longitude and latitude from the profile data
$latitude1 = <?php bp_member_profile_data( 'field=Latitude' );?>; // lat from the profile
$longitude1 = <?php bp_member_profile_data( 'field=Longitude' );?>; //lon from profile
// needs to search for long & latitude from the search box into wp_zip
$latitude2 = "SELECT Latitude FROM wp_zip WHERE wp_zip='$zip' LIMIT 1"; // wp_zip is the zipcode table with lat & lon
$longitude2 = "SELECT Longitude FROM wp_zip WHERE wp_zip='$zip' LIMIT 1"; // wp_zip is the zipcode table with lat & lon
// Create coordinates
$originCoord = new Coordinate($latitude1, $longitude1);
$relativeCoord = new Coordinate($latitude2, $longitude2);
$distCalc = new DistanceWizard();
// Perform calculation
$dist = $distCalc->CalculateDistance($originCoord, $relativeCoord, Measurement::MILES);
// Use result in a way of your choosing
//echo "Distance from Patient's Zipcode: " . $dist; echo " Miles"