Build a simple MySQL geodatabase using GeoIP and PHP_PHP tutorial

WBOY
Release: 2016-07-13 17:26:28
Original
941 people have browsed it

MaxMind's GeoIP is a very useful tool for identifying the country of your web site visitors. But once you have this geographic information, what do you do with it? A common application for this data is geo-targeted advertising. The basic steps for using GeoIP data are pretty simple - you read the visitor's remote IP address, map that address to a country code (using the GeoIP mapping database), and then use that country code to display ad banners designed for that country. . Listing A is a sample PHP script that shows these steps. This script assumes that you have a MySQL database that contains a list of advertising banners, indexed by country code. Once the customer's IP is obtained through the dedicated $REMOTE_ADDR variable, this IP can be mapped to the country code. Then we use this country code to randomly select an advertising banner for that country from the advertising banner list. Pay special attention to the SQL query here - it will first retrieve all records (advertising banners) that match the country code, and the country needs to be returned by the geoip_country_code_by_addr() method, and then randomly select one from each advertising banner. The corresponding file name of the (selected) advertising banner will be dynamically inserted into the HTML page. If you want, you can further combine the ad banner with the click tracking script through this unique ad banner ID to calculate whether your advertising system is successful and effective. Other uses for geographic data Targeted advertising is one of the most common applications of geodatabases. However, you can also use this information to precisely target (different) users with other types of content: weather forecasts, stock information, news headlines, etc. You can also use this data in other ways, such as redirecting users to content in their local language, limiting/granting access to users based on their location, or automatically adjusting the shopping cart display to Use local currency. I will leave the discovery of innovative applications of this technology to you.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531966.htmlTechArticleMaxMind’s GeoIP is a very useful tool for identifying the country of your web site visitors. But once you have this geographic information, what do you do with it? This kind of data...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template