[eluser]Unknown[/eluser]
I've just started with CI and I'm a little stuck.
Getting the error message telling me that the variable users is undefined
Code from my controller:
Code:
function index() {
$query = $this->db->get('users');
$users = $query->result_array();
if ($query->num_rows() > 0) {
$this->load->view('user/index', $users );
}
Code from my view:
Code:
<table>
<tr>
<th>ID</th>
<th>Username</th>
<th>First Name</th>
<th>Last Name</th>
</tr>
<?php foreach($users as $user):?>
<tr>
<td>
<?php echo $user['id']; ?>
</td>
<td>
<?php echo $user['username']; ?>
</td>
<td>
<?php echo $user['firstName']; ?>
</td>
<td>
<?php echo $user['lastName']; ?>
</td>
</tr>
<?php endforeach; ?>
</table>