This is my code
user_controller.php
public function get_users(){
//load the database
$this->load->database();
//load the model
$this->load->model('user_model');
//load the method of model
$this->user_model->select();
return //the data in view
$this->load->view('user_view', $data);
}
user_model.php
function select(){
$query = $this->db->select('barcodeout','barcodein','emp_id','emp_name','amount','time');
$this->db->from('porters');
$query = $this->db->get();
return $query->result();
}
user_view.php
<table>
<tr>
<td><strong>Ticket Out</strong></td>
<td><strong>Ticket In</strong></td>
<td><strong>Emp ID</strong></td>
<td><strong>Emp Name</strong></td>
<td><strong>Amount</strong></td>
<td><strong>Time</strong></td></tr>
<?php foreach($query->result() as $employee){ ?>
<tr>
<td><?=$employee->barcodeout;?></td>
<td><?=$employee->barcodein;?></td>
<td><?=$employee->emp_id;?></td>
<td><?=$employee->emp_name;?></td>
<td><?=$employee->amount;?></td>
<td><?=$employee->time;?></td>
</tr>
<?php }?>
</table>
</div>
</div>
I have tried many things with this, all I get is 'undefined variable' at the end, suggest me with all three MVC codes to get the database records, it will really appreciated, Thanks.