O'Reilly logo

Professional CodeIgniter® by Thomas Myer

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

10.1. One Last Sanity Check of Checkout

When you last worked on the shoppingcart view in Chapter 5, you created a simple table view with associated functionality that allowed the user to add or remove items from their PHP session-based cart.

As a quick reminder, here's the source code for the shoppingcart view:

<h1>Shopping Cart</h1> <div id='pleft'> <?php echo form_open(); ?> <table border='1' cellspacing='0' cellpadding='5'> <?php $TOTALPRICE = $_SESSION['totalprice']; if (count($_SESSION['cart'])){ foreach ($_SESSION['cart'] as $PID => $row){ $data = array( 'name' => "li_id[$PID]", 'value'=>$row['count'], 'id' => "li_id_$PID", 'class' => 'process', 'size' => 5 ); echo "<tr valign='top'>\n"; echo "<td>". form_input($data)."</td>\n"; echo "<td id='li_name_".$PID."'>". $row['name']."</td>\n"; echo "<td id='li_price_".$PID."'>". $row['price']."</td>\n"; echo "<td id='li_total_".$PID."'>".$row['price'] * $row['count']."</td>\n"; echo "<td><a href='#' onclick='javascript:jsRemoveProduct($PID)'> delete</a></td>\n"; echo "</tr>\n"; } $total_data = array('name' => 'total', 'id'=>'total', 'value' => $TOTALPRICE); echo "<tr valign='top'>\n"; echo "<td colspan='3'>&nbsp;</td>\n"; echo "<td colspan='2'>$TOTALPRICE ".form_hidden($total_data)."</td>\n"; echo "</tr>\n"; echo "<tr valign='top'>\n"; echo "<td colspan='3'>&nbsp;</td>\n"; echo "<td colspan='2'><input type='button' name='update' value='update' onClick='javascript:jsUpdateCart()'/></td>\n"; echo "</tr>\n"; echo "<tr valign='top'>\n"; ...

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