I have a php page which allows users to register, when they register, they enter their name, area name such as London and then there x and y co-ordinates. This informaiton is then store in a sql database.
A sample of the database is
Currently I have a php search form which performs a simple query on the register sql table and returns a result which match the users area name, for example, if someone searches for
then it performs the query
$areaname = $_GET['area']; $sql = "SELECT * FROM registered WHERE `areaname` >= '".$areaname."";
There is only ever one person in each area, so it only ever returns one result.
What I want to do is to run the above query, and then, after that, run another query which would return the next 10 rows which are closest to the row which has been found based on the x and y coordinates which have been inputted into each row in the database.
I'm not 100% if using the x and y coordinates will return the closest, but I believe it will.
I also store the latitude and longitude values in each row if anyone thinks that would help return a more accurate result.
Any help would be great as ive been trying to crack this for the last 18 hours and im going no where quick.
Thanks in advance