I am selecting from database and data successfully coming back. I am just not sure how to access element of the array such as username or name or etc. This is the output:
Array ( [0] => stdClass Object ( [id] => 9 [fullname] => خالد الغامدي [membership] => free [username] => kkkkk [password] => 16d7a4fca7442dda3ad93c9a726597e4 [email] => [email protected] [about] => [city] => riyadh [profilepic] => /home2/sdds/public_html/uploads/Red_velvet_cupcakes_with_roses.jpgRed_velvet_cupcakes_with_roses.jpg [mobile] => [telephone] => [address] => [gallery_link] => ) )
and this is the code in the model returning the above:
public function login()
{
$this->db->select('*');
$this->db->from('members');
$this->db->where('username', $this->input->post('username'));
$this->db->where('password', md5($this->input->post('password')));
$query = $this->db->get();
return $query->result();
}
So what to do here? thanks in advance
$query->result()returns an object, not an array. Use$query->result_array()instead if you want an array. It's a common mistake :)