doucongqian6644 2010-03-24 23:04
浏览 9
已采纳

php / mysql将州附加到城市

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!

  • 写回答

4条回答 默认 最新

  • dongwupu5991 2010-03-24 23:08
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂