How can I search based on distance with the Google Maps API?

dictionary, geolocation, google-maps, google-maps-api-3, php

Solution

SELECT latitude, longitude, SQRT( POW( 69.1 * ( latitude - 52.58 ) , 2 ) + 
POW( 69.1 * ( - 1.12 - longitude ) * COS( latitude / 57.3 ) , 2 ) ) AS distance 
FROM location ORDER BY distance

Click Here They provide several ways of calculating the distance - choose what works best for you.

Problem

- So here's the issue... I have a field where users can type in their address (which will be GeoCoded via Google Maps API). - I have several addresses of widgets in my database (saved as address.. again can easily be geocoded). What I need is for the user to type in their address and for a list of my widgets to come up based on distance from their address. I have THOUSANDS of addresses for my widgets and users have an infinite number of addresses obviously. Any ideas? Thanks.

Original source