N
N
nepster-web2015-01-04 18:59:05
PHP
nepster-web, 2015-01-04 18:59:05

How to work with geolocation?

The following thing needs to be done:
The user visits the site, we determine his location (eg Russia Moscow) and show him all records from Moscow.
Actually there is a database of countries and cities, when creating a record, the user specifies the city of the record.
Further, when a user enters the site using various geoIp gadgets, we can determine where he is from, the question is how to make friends with the base with similar geo services?
That is, if using geoIp to get the name of the region, do not look for this region in the database by LIKE? The task is to get the desired city ID from the database.
Please tell me how to link the database of countries and cities with the definition of the user's location?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rikcon, 2015-01-04
@Rikcon

Use Gmaps or Yandex or Sypex Geo API.
I can’t say for sure, I didn’t solve such a problem, but something from the above should help)

S
Sergey Senkevich, 2015-01-04
@ssenkevich

Create in your database a table of links between regions of the selected GeoIP service with your table of countries and regions (region ID in the GeoIP service database, region ID in your database, is_valid - whether the connection is checked or not). You only need to complete this table once. Well, with each GeoIP update, you need to check whether new regions have appeared. You can link automatically (via LIKE), but at the same time, put false in the is_valid field. Then manually check and set is_valid = true.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question