Find the closest location near your address

Can anyone give me a hand with this please? I’ve been looking for something that I can work with, but not having all that much success.

So it’s pretty much just a form in PHP that you would type your address, and a distance you’re willing to travel, then the script would query the DB for the addresses there using google maps API, and turn out with a list of results closest to your address using the distance the end user defined.

Similar to this: http://web.sa.mapquest.com/timhortons/?tempset=search

I guess you’re able to get the latitude and longitude for a location?

You can use this query to query the database:

SELECT * , 6371.04 * acos( cos( pi( ) /2 - radians( 90 - Latitude) )
* cos( pi( ) /2 - radians( 90 - '$latitude' ) ) * cos( radians(
Longitude) - radians( '$longitude' ) ) + sin( pi( ) /2 - radians( 90
- Latitude) ) * sin( pi( ) /2 - radians( 90 - '$latitude' ) ) ) AS
Distance
FROM MyLocations
WHERE ( 6371.04 * acos( cos( pi( ) /2 - radians( 90 - Latitude) ) *
cos( pi( ) /2 - radians( 90 - '$latitude' ) ) * cos( radians(
Longitude) - radians( '$longitude' ) ) + sin( pi( ) /2 - radians( 90
- Latitude) ) * sin( pi( ) /2 - radians( 90 - '$latitude' ) ) ) <1 )
GROUP BY one_id HAVING dist < '$radius'
ORDER BY Distance
LIMIT 0 , $numberOfResults

Where:

[LIST]
[]MyLocations = The table with your locations
Fields:[LIST]
[
]id
[]Name
[
]Latitude
[]Longitude[/LIST]
[
]$longitude = The longitude
[]$latitude = The latitude
[
]$radius = The radius in kilometers
[*]$numberOfResults = The maximum number of results you want[/LIST]

Off Topic:

Wow - bookmarked this one.