Hello
I have been writing searchable directories for years, and generally I have used a form that has a dropdown/select field for states, including an option for "all states", and a separate text field for city. The raw data being searched is always broken down into separate city and state fields within the database. I am using php, mysql and oracle.
However I am becoming aware that many people will enter something like "Salem MA" or "Salem, MA" or "Salem Mass" in the city field, as they are accustomed to doing with google, etc. This cannot be standardized, the query depends on what the viewer enters, and people enter what they enter.
When you go to google maps for example, and type in fresno ca, it automatically knows what the viewer wants. Of course google has hundreds of programmers working on this stuff and I am just one guy...
I am thinking about a logical progression as follows:
Let's say the form has $state select box including "all states", and $city text field.
If $state is not specified AND if $city contains a space, grab the following the final space and identify as $end
1) If $end equals 2 letters, check states db to see if $end matches state abbreviation
else
2) If $end is longer than 2 letters, check states db to see if $end LIKE state name
then
3) If there is no match for 1 or 2, search city database to see if $city is LIKE city name. For example, Los Angeles would match.
Let's say there is a typo, Los Angeles CZ, or Los Angeles Calf -- these would fail 1, 2 and 3. Chop off the final $end from $city, and Los Angeles would match.
Am I taking this too far?
Next, search a geo database, look for proximity
I have worked with chained select fields before, where the viewer first selects state then the city select field is populated with a list of cities in the state, but this is not user-friendly -- too many people don't get it.
Any suggestions much appreciated....
Cheers,
Mike
I have been writing searchable directories for years, and generally I have used a form that has a dropdown/select field for states, including an option for "all states", and a separate text field for city. The raw data being searched is always broken down into separate city and state fields within the database. I am using php, mysql and oracle.
However I am becoming aware that many people will enter something like "Salem MA" or "Salem, MA" or "Salem Mass" in the city field, as they are accustomed to doing with google, etc. This cannot be standardized, the query depends on what the viewer enters, and people enter what they enter.
When you go to google maps for example, and type in fresno ca, it automatically knows what the viewer wants. Of course google has hundreds of programmers working on this stuff and I am just one guy...
I am thinking about a logical progression as follows:
Let's say the form has $state select box including "all states", and $city text field.
If $state is not specified AND if $city contains a space, grab the following the final space and identify as $end
1) If $end equals 2 letters, check states db to see if $end matches state abbreviation
else
2) If $end is longer than 2 letters, check states db to see if $end LIKE state name
then
3) If there is no match for 1 or 2, search city database to see if $city is LIKE city name. For example, Los Angeles would match.
Let's say there is a typo, Los Angeles CZ, or Los Angeles Calf -- these would fail 1, 2 and 3. Chop off the final $end from $city, and Los Angeles would match.
Am I taking this too far?
Next, search a geo database, look for proximity
I have worked with chained select fields before, where the viewer first selects state then the city select field is populated with a list of cities in the state, but this is not user-friendly -- too many people don't get it.
Any suggestions much appreciated....
Cheers,
Mike