Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 684719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:50:53+00:00 2026-05-14T01:50:53+00:00

Having a hard time figuring out the best way to do this… I have

  • 0

Having a hard time figuring out the best way to do this…

I have a search function that takes “search terms” and “search location”. In the location input, I have an suggestion feature that brings up “city, state abbreviation” but it seems some users just do not use it(or can’t) so they end up entering just a city name… I need to append the state abbreviation after the form is submitted. I have a table with all city and state names in the U.S. but the problem is… there are multiple cities with the same name in different states… I would like to add the state abbreviation for the state that the city is most popular for(does that make sense?).

For example, if the user enters “Miami” I would like it to become “Miami, FL” as opposed to “Miami, WV”…

Any ideas?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:50:54+00:00Added an answer on May 14, 2026 at 1:50 am

    You may want to consider the correlation between the “city population” and its “general popularity”.

    Therefore one easy option might be to gather the population of each city, store it in the database, and if a city name is used that you need to disambiguate, you can choose the one with the largest population.

    The references in the following Wikipedia article might be useful: List of US cities by population.


    Google Maps resolves disambiguations in a similar manner, even though the weighting might be different:

    http://maps.google.com/?q=Miami

    http://maps.google.com/?q=Miami,WV

    I used to think Google Maps also takes into consideration the current viewport when resolving such issues, but searching for Miami while zoomed into the West Virginia still takes you to Florida.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a hard time figuring out the best way to pass simple values
Not the biggest whiz on math here... having a hard time figuring this out.
I am having a hard time figuring out this problem. My app has iAds
I'm pretty new to this stuff and having a hard time figuring out how
I'm having a hard time figuring out how to architect the final piece of
I'm having a hard time figuring out how Firefox and Chrome determining what fields
My company is having trouble figuring out the best way to manage our builds,
I'm having a hard time figuring out how to implement a factory pattern in
I'm having a hard time figuring out what I'm doing wrong. I want do
I'm having a really hard time figuring out the scoping issue with the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.