Jump to content
Sign in to follow this  
GypsyBoy

Calculating distance between 2 post codes

Recommended Posts


I’m new to php and MySQL, and i'm just getting my feet dirty...

Basically i am working on a message board, i need to be able to post a thread like you would do normally and also ask for post code, to be stored with the thread.

Then I want to modify search.php and create a field where you type post code of your liking and have it compared WITH thread post code and then calculate the distance  between  post code in a thread and   post code you type into search

Does that make sense? 

How do I go about that?.

Here’s a good one:

http://www.geopostcode.org.uk/findmynearest.php

Any thing else? Oh and I need a UK version of this (for now) as you probably guessed!


 

Edited by GypsyBoy

Share this post


Link to post
Share on other sites

In general, you need a database listing the approximate center of each area using lat/long, and then you just use one of the existing algorithms to find the difference between 2 coordinates.  It's not going to be exact obviously, because you're only finding the distance between the approximate centers of each area, but that's how they do it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×