#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    152
    Rep Power
    12

    Return mysql database results dependent on town entered


    Hi

    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

    Thank you

    Ian
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    50
    Not only possible, pretty standard stuff.

    Your description is too vague to say more.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    152
    Rep Power
    12
    Hi EEsterling

    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
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,296
    Rep Power
    7170
    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.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    152
    Rep Power
    12
    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
  10. #6
  11. For POny!
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Amsterdam
    Posts
    416
    Rep Power
    115
    edit: never mind I misread the question
    Last edited by aeternus; December 28th, 2012 at 10:53 AM.

IMN logo majestic logo threadwatch logo seochat tools logo