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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <?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> </div> </body> </html> 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!
blog comments powered by Disqus |
|
|
|
|
|
|
|