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

Showing the cart to our clients

This task is also very easy to accomplish with the new cart library. We will need a controller and a view. Just go to application/controllers/shop.php, and add a new function to it; show_cart would be a good name:

function show_cart()
{
$this->load->helper('form');
$this->load->view('cart');
}

Nothing much happening there, we only load the form helper and the cart view. We will do most of the work in application/views/cart.php:

<h1>This is our cart</h1> <?php //Open the form and point it to the update function echo form_open('shop/update'); ?> <table border="2"> <tr> <th>Product</th> <th>Quantity</th> <th style="text-align:right">Price</th> <th style="text-align:right">Total</th> </tr> <?php $i = 1; ?> <?php //Then ...

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