I get error Fatal error: Cannot use object of type stdClass as array in my controller name is Useraccount
function userList() {
$result['data'] = $this->Useraccount_mod->getUser_list();
$data['userlist']=$result['data'] ;
$this->load->view('Useraccount/Userlist', $data);
}
and model name is Useraccount_mod
function getUser_list() {
$query=$this->db->query("select * from users");
return $query->result();
}
and view name is Userlist
<tbody>
<?php
if ($userlist > 0) {
foreach ($userlist as $row) {
?>
<tr>
<td width="100"><?php echo $row['username']; ?></td>
<td width="100"><?php echo $row['name']; ?></td>
<td width="100"><?php echo $row['address']; ?></td>
<td width="100"><?php echo $row['creatdate']; ?></td>
<td width="100"><?php echo $row['updateddate']; ?></td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="3" align="center"><strong>No Record Found</strong></td>
</tr>
<?php
}
?>
</tbody>
A PHP Error was encountered Severity: Error Message: Cannot use object of type stdClass as array Filename: Useraccount/Userlist.php Line Number: 38 Backtrace: