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 Quote Link to comment 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. Quote Link to comment 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?! Quote Link to comment 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 Quote Link to comment 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` ?? Quote Link to comment 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 Quote Link to comment 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!! Quote Link to comment 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.