[eluser]Unknown[/eluser]
how to store the items to the cart if the item are coming from database
here is the code of view file below which does not show me the items added to the cart.
<?
else if($page_req=='shoppinglist') { ?>
<form action="<?=base_url()?>checkout" method="post">
<table><tr><td>Product Name </td><td>Price</td><td>Quantity</td></tr>
<tr>
<? foreach($this->cart->contents() as $items)
{
?>
<td><? echo $items['pname']; ?> </td>
<td><? } ?> </td>
</tr></table>
<input type="text" name="qty">
</form>
<? } ?>
here is the controllers code below
else if($req=='shoppinglist')
{
$req=$this->uri->segment(4);
$sqlselect="select * from shopping where id='$req'";
$query=mysql_query($sqlselect) or die(mysql_error());
while($rec=mysql_fetch_array($query))
{
$id=$rec['id'];
$pname=$rec['name'];
$pprice=$rec['price'];
$qty=$this->input->post('qty');
}
$this->load->library('cart');
$productarray=array('id'=>$id,'pname'=>$pname,'pprice'=>$pprice,'qty'=>$qty);
print_r($productarray);
//$data['productarray']=$productarray;
$cartinsert=$this->cart->insert($productarray);
$data['title'] = 'Ziplance Lab Hosting Service| Penny auction script | Dating script | Freelance script | Zip Lance Lab | Ziplancer';
$data['meta_keywords'] = 'Excellent Penny auction script, Ziplane lab product list.';
$data['meta_description'] = 'Zip Lance Lab providing excellent product at cheapest rate.';
$data['page_req']='shoppinglist';
$this->load->view('full_page',$data);
}