这是我在控制器中的代码......
function get_product(){
$purchase_id=$_POST['purchase_id'];
if($purchase_id!=''){
//$post_array['cart']='';
$res = $this->db->query("select * from phppos_productdetails WHERE
purchase_id='$purchase_id'");
?>
<tr>
<th>Product Name</th>
<th>Quantity </th>
<th>Unit </th>
<th>Unit Rate</th>
<th>Action</th>
</tr>
<?php
$i=0;
foreach($res->result() as $row )
{
$sess_products[$i]['product_id'] = $row->product_id;
$sess_products[$i]['quantity'] = $row->quantity;
$sess_products[$i]['unit'] = $row->unit;
$sess_products[$i]['unit_rate'] = $row->unit_rate;
$this->session->set_userdata('sess_products',$sess_products);
$query = $this->db->query("SELECT product_name FROM phppos_product WHERE
product_id='".$row->product_id."'");
foreach ($query->result() as $row1 )
{
$product_name=$row1->product_name;
}
echo "<tr>";
echo "<td>".$product_name."</td>";
echo "<td>".$row->quantity."</td>";
echo "<td>".$row->unit."</td>";
echo "<td>".$row->unit_rate."</td>";
echo "<td><a href='javascript:void(0)' rownum='".$i."' class='remove_from_cart'><img src='images/close.png'/></a></td>";
echo "</tr>";
$i++;
}
}
}
这是由ajax调用调用的控制器中的函数。那么如何将该查询结果存储在codeigniter ??
中的会话数组中我正在接受这样的
$demo_arr['cart']= $this->session->userdata('sess_products');