Beruflich Dokumente
Kultur Dokumente
{ sales@ip2location.com }
Online advertising is another way to promote company products. It’s very important to
show the right advertisements to the right consumers to have an optimum respond. A
company selling their products in Japan showing their advertisement to visitors from
United States is totally ineffective. On the other hand, localized advertisements catch
visitor attention and improve sales.
In this tutorial, we will learn how to switch advertisement to show base on visitor’s
origin. nstead of loading the full database with 50000+ records, we could simplify this
tutorial with assumption only two different IP address ranges in the world. IP addresses
0.0.0.0 - 126.255.255.255 originates from United States. Meanwhile, IP addresses
127.0.0.0 - 255.255.255.255 originate from Japan. Here we are creating a database
"IP2Location" with table "IPCountry" that consists of two IP address range records.
PC:
Linux/Unix:
<?php
// Replace this MYSQL server variables with actual configuration
$mysql_server = "mysql_server.com";
$mysql_user_name = "UserName";
$mysql_user_pass = "Password";
// SQL query string to match the recordset that the IP number fall between
the valid range
$query = "SELECT * FROM IPCountry WHERE $ipno <= ipTO AND $ipno>=ipFROM";
if ($countrySHORT == "JP")
{
// If the visitors are from JP, show advertisement from JP
echo "<img src="Japan.jpg" border="0" width="100" height="200">";
}
else {
// Otherwise, show other advertisement
echo "<img src="US.jpg" border="0" width="100" height="200">";
}
exit;