Every user in my database has their latitude and longitude stored in two fields (lat, lon)
The format of each field is:
lon | -1.403976
lat | 53.428
Using just SELECT * FROM Table WHERE lat between $minlat and $maxlat
will not be accurate enough.
The correct way to query distance is using the coordinates in radians.
Here is a handy reference - http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates
For example:
And if you want to do the order by and show the distance:
Edited for @Blazemonger and the avoidance of doubt :) If you want to work in degrees instead of radians:
You could easily wrap this up into a class that accepted Radians or Degrees from the information provided above.