| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Senior Member
Join Date: Aug 2006
Location: Warrington, UK
Posts: 813
|
PHP Postcode Search
I am in the middle of a project for a client and they have asked if it is possible for a postcode search facility very similar to the one on this site: Oven Cleaning UK where the user inputs the first half of their postcode and a page will appear with a franchise/store in their given area. I have been trying to learn PHP for a while now and only really know the basics. I managed to find hopefully something similar to what they are after on this site: HM2K.com » How to search by nearest UK postcode in PHP but am not sure how to implement. Can anyone shed any light on how to go about this? I have tried to import the Postcode CSV into phpMyAdmin but had no look either. Cheers |
|
|
|
|
|
#2 (permalink) |
|
Spare Parts
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 6,874
|
My recomendation is not to build something yourself but use one of the online services that give you a piece of script to insert and charge per search. Post code DB changes as new streets are built and any download versions are incomplete. There is one company that does this I am thinking of but can remember URL, I will look it out. |
|
|
|
#4 (permalink) |
|
Senior Member
Join Date: Aug 2006
Location: Warrington, UK
Posts: 813
|
cheers for that hound, im not sure if they would like to opt for that though, are there any more roads i could go down? that tutorial seems perfect, im just not 100% sure how to implement it properly. |
|
|
|
#5 (permalink) |
|
Shun the non-believer
|
If you don't need to calculate distance or get the nearest outside of their district then just returning the results of the first 2 letters of the postcode (presuming they're UK postcodes) might be enough. Although this isn't the best way. Ideally you want to utilise the long/lat coordinates for each postcode of your stores and compare it to the users coordinates. To do that you're going to need to tap in to a service, such as above. I did something similar recently here: Lactofree - Stockists The above uses a custom database that I created and keeps the coordinates locally, which aids speed. The stuff like getting the users coordinates are all done through the Google Maps API. |
|
|
|
#7 (permalink) |
|
Web Developer
Join Date: Oct 2006
Posts: 3,967
|
Postcode anywhere is a piece of piss, just stick in some javascript (that they provide) onto your form and you have the basic bit working, you can improve it by having a failover in PHP incase JS is disabled - but this isn't required. |
|
![]() |
|