This project is with E-Commerce. There is option to Add to Cart. When user click on add, product will be added to his cart as well and working fine.
But finally when user click place order button Admin will receive Mail with products. That E-mail body should content should display like below.

I tried with using foreach and echo data row by row. But its useless .
Question is - I want retrieve data from cart and add to Above table Format and then it will end with mailing. How to archive this with CI?
Html Table Format
$to = '[email protected]';
$msg .= '
<table id="table" border="0" cellpadding="5px" cellspacing="1px" style="border: 1px solid #eee">
<tr id= "main_heading">
<td>Name</td>
<td>Price</td>
<td>Qty</td>
<td>Amount</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>';
Note : there is no special code to this(inserting and updating). all the codes are same with ellislab.com
CART VIEW

If i use
$as = $this->cart->contents();
print_r($as);
it shows

Controller
public function index()
{
$data['category'] = $this->Product_Model->get_category();
$data['category2'] = $this->Product_Model->get_category2();
$data['product'] = $this->Product_Model->get_product();
$data['right_brand'] = $this->Product_Model->get_right_brand();
$data['right_prod'] = $this->Product_Model->get_right_product();
$data['brand'] = $this->Product_Model->get_brand_names();
$data['products'] = $this->Product_Model->get_cart_items();
$data['head'] = $this->Product_Model->check_cart();
$this->load->view('template/header', $data);
$this->load->view('template/right_sidebar', $data);
$this->load->view('pages/cart', $data);
$this->load->view('template/foot');
}
public function insert_cart()
{
$data = array(
'id' => $this->input->post('pid'),
'qty' => $this->input->post('qty'),
'price' => $this->input->post('price'),
'name' => $this->input->post('head'),
);
$this->cart->insert($data);
}
function remove($rowid)
{
if ($rowid==="all")
{
$this->cart->destroy();
redirect('index.php/main');
}
else
{
$data = array(
'rowid' => $rowid,
'qty' => 0
);
$this->cart->update($data);
}
// This will show cancle data in cart.
redirect('index.php/cart');
}
function update_cart()
{
$cart_info = $_POST['cart'] ;
foreach( $cart_info as $id => $cart)
{
$rowid = $cart['rowid'];
$qty = $cart['qty'];
$data = array(
'rowid' => $rowid,
'qty' => $qty
);
$this->cart->update($data);
}
redirect('index.php/cart');
}
use
jqueryand capture thehtml tablethat you want to send as email. and pass the variable to the email function usingajax, try this,jquery veriable = htmlstring
also you can use
jqueryserializemethod to get all form inputs.https://api.jquery.com/serialize/
CI ocontroller