Using GeoIP and PHP to build a simple MySQL geodatabase _php tutorial

Source: Internet
Author: User
Tags geoip maxmind
Maxmind's GeoIP is a very useful tool to identify the country where your Web site visitors are located. But once you have this geographic information, should you deal with it? A common application of this data is advertising that is distributed for geographic locations. The basic steps for using GEOIP data are quite simple-you read the remote IP address of the visitor, map the address to a country code (using the GEOIP Mapping database), and then use the country code to display the ad strips designed for that country. List A is a sample PHP script that shows these steps. This script assumes that you have a MySQL database that contains a list of ad bars and is indexed according to the country code. Once the client's IP is acquired through a dedicated $REMOTE_ADDR variable, the IP can be mapped to a country code. Then we use this country code to randomly select an ad bar for that country from the ad bar list. Pay particular attention to SQL queries-it first retrieves all the records that match the country code (the banner), and the country needs to be returned by the GEOIP_COUNTRY_CODE_BY_ADDR () method, and then randomly select one from each ad bar. (selected) The corresponding filename of the banner will be dynamically inserted into the HTML page. If you want, you can use this unique banner ID to further combine the banner with the click-Tracking script to count the success of your ad system. Other uses of geographic data targeted advertising is one of the most common applications of geodatabases. However, you can also use this information to accurately provide other types of content for (different) Users: Weather forecasts, security information, headlines, and so on. You can also use this data in other ways, such as rebooting users to content written in their native language, restricting/giving them access based on where they are located, or automatically adjusting the display of the cart to use the local currency. I will leave the discovery of this technology innovation application to you.

http://www.bkjia.com/PHPjc/531966.html www.bkjia.com true http://www.bkjia.com/PHPjc/531966.html techarticle Maxmind's GeoIP is a very useful tool to identify the country where your Web site visitors are located. But once you have this geographic information, should you deal with it? This data ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.