In my table I have two rows but when I print_r
the $data
that this model function is connected to it is only returning the second row in the db why?
Model Function:
function getAllUsers()
{
$query = $this->db->get('users');
foreach($query->result_array() as $row)
{
$row['id'];
$row['fName'];
$row['lName'];
$row['email'];
$row['password'];
}
return $row;
}
Because
$row
is the loop variable, it will only hold the data from the last iteration after the loop has exited.Do it like this:
In your controller:
In your view