O'Reilly logo

CodeIgniter 1.7 by David Upton, Jose Argudo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding products to the cart

To keep with the example, we will build a list of products, with their prices and an Add button. Now create a controller in application/controllers, call it shop.php, and for the moment, only add the following code:

<?php
class Shop extends Controller
{
function Shop()
{
parent::Controller();
}
function index()
{
$this->load->view('home');
}
}

We are only defining the class, the constructor, and creating an index method, which calls the view. This view will be the place where we build our list of products, but for now create the file in application/views/home.php, and place some simple content in it:

<h1>This is our shop home page</h1>

If we want to check that everything is working fine, we only need to go to http://localhost/codeigniterc/index.php/shop ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required