开发者

Location based information

开发者 https://www.devze.com 2022-12-12 09:48 出处:网络
I would like to show information on my website based on user\'s geography. In my current design would not want the user to enter their location/zip code.

I would like to show information on my website based on user's geography. In my current design would not want the user to enter their location/zip code. Using IP I can find user's location but how do i leverage this information to show relevant events/information from surrounding cities/town.

Th开发者_如何学编程anks


Based on IPs, you only have a certain accuracy with showing location. You should have a option that lets them enter their city/state or zip code.

Once you have long/lat, you just need to run a query to find records in your database a specific distance from that long/lat.

PHP/MySQL: Select locations close to a given location from DB


http://www.ipinfodb.com/ip_location_api.php

this will send you an xml response with the pertinent information


Lets say you can get their City from the IP address. You would need a database of cities with ID's that would pertain to other database entries. Like:

database table cities    database table restaurants
---------------------    --------------------------
ID       City            ID     city_id     name

1        Los Angelos     1      1           Big Al's

Then you could search for restaurants that have the city_id of the city you got from their IP.

There are so many different approaches to relational databases. This is just one small example.

0

精彩评论

暂无评论...
验证码 换一张
取 消