Use GeoIP and PHP to build a simple MySQL geographic database. MaxMind GeoIP is a very useful tool used to identify the country where your Web site visitors are located. But once you have the geographic information, what should you do? This type of data MaxMind GeoIP is a very useful tool used to identify the country where your Web site visitors are located. But once you have the geographic information, what should you do? A common application of such data is the advertisement for geographic location. The basic steps for using GeoIP data are quite simple-you read the visitor's remote IP address (using GeoIP ing database) to map this address into a country code, the country code is then used to display ads designed for the country. List A is a php sample script that displays these steps. This script assumes that you have a MySQL database that contains a list of advertisement entries and is indexed according to the country code. Once the customer's IP address is obtained through the special $ REMOTE_ADDR variable, the IP address can be mapped to the country code. Then we use the country code to randomly select an advertisement for the country from the advertisement bar list. Pay special attention to the SQL query -- it first retrieves all records that match the country code (advertisement bar), and the country needs to be returned by the geoip_country_code_by_addr () method, then, randomly select one from each advertisement bar. (Selected) the corresponding file name of the ad bar will be dynamically inserted into the HTML page. If you want to, you can use this unique ad ID to further combine the ad and click tracking scripts to determine whether your advertising system is successful or not. Other use of geographic data targeted advertising is one of the most common applications of geographic databases. However, you can also use this information to precisely provide other types of content for (different) users: weather forecasts, securities information, news headlines, and so on. You can also use this data in other ways. for example, you can redirect users to content written in their local language and restrict/grant them access permissions based on their location, or automatically adjust the display of the shopping cart to use the local currency. I will leave you the right to discover this technological innovation application.
Bytes. But once you have the geographic information, what should you do? This data...