Home arrow PHP arrow Page 4 - Using Code Igniter to Build an IP-to-Country Mapping Application

Finishing the IP-to-country mapping application - PHP

Adding geo-location capabilities to a web site isnít too hard; itís possible to develop an IP-to-country mapping program with PHP, which can be incorporated into a site in a few easy steps. If youíre interested in learning how to build this application, then keep reading. This is the final installment of a four-part series that covers developing an IP-to-country mapping application with PHP.

  1. Using Code Igniter to Build an IP-to-Country Mapping Application
  2. Review: Building dynamic web pages in distinct languages using the iptocountry MySQL table
  3. Building a simple IP-to-country mapping application with the Code Igniter framework
  4. Finishing the IP-to-country mapping application
By: Alejandro Gervasio
Rating: starstarstarstarstar / 3
February 24, 2009

print this article



In the previous section, I explained how to build a simple controller class to implement the logic required to generate a "products" web page section in different languages. Assuming that you understand how this controller works, it's time to create the generic view file that renders this product-related data in the form of a web page.

That being said, here's how this simple view file looks:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />



<?php foreach($products->result_array() as $product):?>

<div id="container">

<h2><?php echo $product['name'];?></h2>

<p><?php echo $product['description'];?></p>

<p><?php echo $product['price'];?></p>

<p><?php endforeach;?></p>




As you can see, the above view file implements the logic necessary to loop through these fictional products and displays their different items, including their names, descriptions and prices respectively. Simple and effective!

Having shown you how to define a basic view file with Code Igniter, the development of this IP-to-country application is completed. Of course, this is only an illustrative example that demonstrates how to build a program like this using Code Igniter, but you shouldn't have major troubles adapting the source code for working with a different framework.

Final thoughts

It's hard to believe, but we've come to the end of this series. Hopefully, this journey has been useful, since you learned how to build different sorts of IP-to-country mapping applications with PHP using a single MySQL lookup table. From this point onward, you can use all of the code samples included in these tutorials and start creating your own mapping programs in PHP.

See you in the next PHP web development tutorial!

>>> More PHP Articles          >>> More By Alejandro Gervasio

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: