warid7840288 Posted April 11, 2007 Share Posted April 11, 2007 hi i am developing a car web and want to make an advance search. everything is ok but one problem that how to search the car against the postcode and how much miles away from that postcode same like http://www.fish4.co.uk/iad/cars thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/46551-uk-postcode/ Share on other sites More sharing options...
redbullmarky Posted April 11, 2007 Share Posted April 11, 2007 you need to look for 2 things: 1, a UK postcode database which also holds the longitude/latitude of the postcode. Getting a database with a full collection of the first part of the postcode (ie, B27) is a pretty straightforward google search. If you want the full postcode (ie, SE1 4XU) then you may have to do a bit more digging or pay for it (if you find it via the former, let me know ) 2, another google search that converts 2 longitude/latitude pairs to a straight line distance. again, there are many different implementations but finding one shouldnt be too tricky. Then it's simply a case of storing the location of each car and making the calcs as you go. Quote Link to comment https://forums.phpfreaks.com/topic/46551-uk-postcode/#findComment-226613 Share on other sites More sharing options...
b83s Posted April 11, 2007 Share Posted April 11, 2007 You could try to get a 4 digit zipcode from googlemaps or yahoo maps and translate that to latitude longitude coordinates. After you stored that in your database you can search on distance. Hope this link will get you futher: http://ben.milleare.com/2006/09/03/calculating-distance-with-latitude-and-longitude/ Quote Link to comment https://forums.phpfreaks.com/topic/46551-uk-postcode/#findComment-226615 Share on other sites More sharing options...
redbullmarky Posted April 11, 2007 Share Posted April 11, 2007 and here's a postcode resource I mentioned, which gives longitude/latitude for the first part of the postcode. http://www.jibble.org/ukpostcodes/ edit: you might find some good references here too: http://en.wikipedia.org/wiki/UK_postcodes#References edit 2: this one seems to do the lot: http://www.pjenkins.co.uk/blog/index.php/2007/04/04/uk_post_code_distance_calculation/ b83s, from my experience, both google and yahoo have rubbish support for UK postcodes, but the link you provided is a good one Quote Link to comment https://forums.phpfreaks.com/topic/46551-uk-postcode/#findComment-226623 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.