[eluser]sparbier[/eluser]
I merely want to put the users email-address on the page, so I query the database only for the e-mail field by comparing with the id in the sessions userdata, which results in one single field in one single row.
Now that query result is in the special format of CI, i.e. apparantly I can not directly treat it just as an array (error reads something like "cannot treat CI_DB... as array") or straightforward as a string.
The code below does work, but it looks a bit stupid to me to go through a foreach if I know already that there is only one row.
any suggestions?
Code:
$i = $this->session->userdata('id');
$this->db->select('email')->from('users')->where('id', $i);
$me = $this->db->get();
foreach ($me->result() as $row)
{
echo $row->email;
}