I don't know where the foreach variable came from ... I got it from copypaste from my previous program
Message: Undefined variable: barang
Message: Invalid argument supplied for foreach()
this is my view eror
<?php
foreach($barang as $i): ?>
<tr>
<td><?=$i->id_barang;?></td>
<td><?=$i->id_jenis;?></td>
<td><?=$i->nm_barang;?></td>
<td><?=$i->stok;?></td>
<td><?=$i->hrg_beli;?></td>
<td><?=$i->jual;?></td>
</tbody>
<?php endforeach ?>
this is my controller to show the table
public function __construct(){
parent::__construct();
$this->load->model('model_barang', 'barang');}
public function index(){
$data['barang'] = $this->barang->tampil_data();
$this->load->view('view');}
this is my model to show the table
function tampil_data(){
$data = $this->db->get('barang');
return $data;
}