December 28th, 2012, 06:31 AM
Return mysql database results dependent on town entered
I am bit stuck, I want to return results from a mysql database when a user enters their town or postcode in for example below
they enter in their town or post code and a list of area managers is displayed closest to their town or postcode along with their contact number
Is that possible
December 28th, 2012, 09:09 AM
Not only possible, pretty standard stuff.
Your description is too vague to say more.
December 28th, 2012, 09:13 AM
Thank you for the reply
For example I have entered two records in a mysql database
and on the php page I have a text field called town and the user enters their town in and I want the php to display results matching that town name or close to that town name if there is no match for that town name
December 28th, 2012, 10:35 AM
Actually what you want to do is completely clear, the technical details of your system are the vague part.
For example: what location data do you store for your managers - if the store the post code and town name, then you can perform a simple equals select query to fetch a list of managers belonging to that post code or town. If you store one but not the other, then you're going to need a database of locations so that you can map between them.
The part about fetching nearby results (that don't match the post code or town name exactly) is more complicated. In order to do this, you need a database the maps post codes and town names to lat/long coordinates. Then when the user enters a post code or town name, you look up its lat/long and then perform a radius search around it to locate other post codes / town names within that area. Modern versions of MySQL have built-in support for performing a spatial search like this.
December 28th, 2012, 10:36 AM
I will be storing the town name but can store the post code as well if it is easier than just storing the town name
December 28th, 2012, 10:48 AM
edit: never mind I misread the question
Last edited by aeternus; December 28th, 2012 at 10:53 AM.