I really need help . i don't know to solve Undefined variable: chart
ERROR
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: chart
Filename: shop/header.php
Line Number: 242
My Controller
function mychart($id_user)
{
$where = array('id_user' => $this->session->userdata('id_user'));
$datachart['chart'] = $this->m_product->tampil_chart($where,'chart')->result();
$this->load->view('shop/header',$datachart);
}
My Model
function tampil_chart($where,$table)
{
$datachart = $this->db->get_where($table,$where);
return $datachart->result();
}
View(shop/header)
<div class="header-cart-content flex-w js-pscroll">
<?php foreach($chart as $a){
?>
<ul class="header-cart-wrapitem w-full">
<li class="header-cart-item flex-w flex-t m-b-12">
<div class="header-cart-item-img">
<img src="<?php echo base_url() ?>assets/user/images/item-cart-01.jpg" alt="IMG">
</div>
<div class="header-cart-item-txt p-t-8">
<a href="#" class="header-cart-item-name m-b-18 hov-cl1 trans-04">
<?php echo $a->id_product ?>
</a>
<span class="header-cart-item-info">
<?php echo $a->jumlah ?>
</span>
</div>
</li>
</ul> <?php } ?>