Searching By City Name

Discussion in 'Databases' started by rzvagelsky, Oct 19, 2006.

  1. #1
    Hey everyone.

    I am currently using php to search a zip code database and display results by radius. Lately I have been considering a "search by city name" feature as well. I do have some general ideas on how to go about it, but I would like know if someone has a proven method of integrating the feature.

    I appreciate any feedback.
     
    rzvagelsky, Oct 19, 2006 IP
  2. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #2
    If your zip code database has city names, then it's just 1 query.

    SELECT * FROM $zipdb WHERE city='$city';

    Where $city is the city name entered by the searcher, and $zipdb is the table name.

    Alternatively, you can also use:
    SELECT * FROM $zipdb WHERE city LIKE '%$city%';

    which will probably output more general results, depending on what is being searched for...

    Hope that helps you.
    Bye :)
     
    JEET, Oct 19, 2006 IP
    rzvagelsky likes this.