scarhand Posted October 3, 2009 Share Posted October 3, 2009 i have 3 tables: 1 contains people with their city (comes from other table) and the range (int, 1-20) they want to be found in (in miles) 1 contains cities and the beginning of the postcode (i.e. BB2) 1 contains cities and their logitudes/latitudes what i am trying to do is select the people according to a postcode someone enters. if this postcode is for a city within their range then the person should be selected from the DB. i have this php code: // Latitude calculation $limit = (1 / 69.1703234283616) * $radius; $latitude_min = $latitude - $limit; $latitude_max = $latitude + $limit; // Longitude calculation $limit = (1 / (69.1703234283616 * cos($userLat * (pi/180)))) * $radius; $longitude_min = $longitude - $limit; $longitude_max = $longitude + $limit; now heres the hard part. i dont know how i am going to select the people from the DB, depending on what postcode was entered and their range. can someone help me out a little here? Link to comment https://forums.phpfreaks.com/topic/176392-selecting-results-by-postcode-longitude-latitude/ Share on other sites More sharing options...
.josh Posted October 3, 2009 Share Posted October 3, 2009 select location from table where (latitude between $latmin and $latmax) and (longitude between $lonmin and $lonmax) obviously you must replace the table, column and variable names with your own. Link to comment https://forums.phpfreaks.com/topic/176392-selecting-results-by-postcode-longitude-latitude/#findComment-929722 Share on other sites More sharing options...
kickstart Posted October 4, 2009 Share Posted October 4, 2009 Hi This thread might help you:- http://www.phpfreaks.com/forums/index.php/topic,266134.0.html All the best Keith Link to comment https://forums.phpfreaks.com/topic/176392-selecting-results-by-postcode-longitude-latitude/#findComment-930121 Share on other sites More sharing options...
Zane Posted October 4, 2009 Share Posted October 4, 2009 Actually, this is a more accurate thread.. Moved to the repository just for reasons such as this http://www.phpfreaks.com/forums/index.php/topic,208965.0.html Link to comment https://forums.phpfreaks.com/topic/176392-selecting-results-by-postcode-longitude-latitude/#findComment-930182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.