textbox Posted May 20, 2007 Share Posted May 20, 2007 Does anyone know of an api or db i can query to find out the city of a certain postcode without filling in the information in a database myself. I want the ability to allow users to enter their postcode, which will return their city. Any help or ideas would be great! Nick Link to comment https://forums.phpfreaks.com/topic/52215-solved-finding-out-location-from-a-post-code/ Share on other sites More sharing options...
BlackenedSky Posted May 20, 2007 Share Posted May 20, 2007 Look for a premade table. There's bound to be one out there. Alternatively find a site with a list of the postcodes and convert it to a database using a program such as "csv converter" (not sure if that's the right title). Had to do a similar thing with a list of countries and list of regions. Found a premade database of countries and a text list of regions which I converted using the above program. Link to comment https://forums.phpfreaks.com/topic/52215-solved-finding-out-location-from-a-post-code/#findComment-257536 Share on other sites More sharing options...
textbox Posted May 20, 2007 Author Share Posted May 20, 2007 Thanks for that. Are tables like this easy to find through Google? Or are there sites who provide searches like this?! Link to comment https://forums.phpfreaks.com/topic/52215-solved-finding-out-location-from-a-post-code/#findComment-257541 Share on other sites More sharing options...
BlackenedSky Posted May 20, 2007 Share Posted May 20, 2007 easy to google: e.g. "list of uk postcodes" gave me this: http://en.wikipedia.org/wiki/List_of_postcode_areas_in_the_United_Kingdom copy into txt file, edit as needed, convert using program which will give you the sql code to create the table Link to comment https://forums.phpfreaks.com/topic/52215-solved-finding-out-location-from-a-post-code/#findComment-257544 Share on other sites More sharing options...
textbox Posted May 20, 2007 Author Share Posted May 20, 2007 Thanks for that. As ann add on to this, how would i set the query up to return the area? SELECT city FROM `postcodes` WHERE $postcode = `city` ?? Link to comment https://forums.phpfreaks.com/topic/52215-solved-finding-out-location-from-a-post-code/#findComment-257563 Share on other sites More sharing options...
PC Nerd Posted May 20, 2007 Share Posted May 20, 2007 select city from postcodes where postcode = $postcode Link to comment https://forums.phpfreaks.com/topic/52215-solved-finding-out-location-from-a-post-code/#findComment-257576 Share on other sites More sharing options...
textbox Posted May 20, 2007 Author Share Posted May 20, 2007 thanks pc nerd i'll give it a try!! Link to comment https://forums.phpfreaks.com/topic/52215-solved-finding-out-location-from-a-post-code/#findComment-257583 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.