I want to get a list of email addresses from the database, what I have tried are here:
In my model:
public function get_email_address_by_sector($search_by, $search_field)
{
$this->db->select('*');
$this->db->like($search_by, $search_field);
$query = $this->db->get('tb_company');
$row = $query->row_array();
return $row['email'];
}
I want to see the data in the array with this controller:
public function get_email_address($search_by, $search_field)
{
$recipients = $this->company_model->get_email_address_by_sector($search_by, $search_field);
print_r($recipients);
}
What does row_array()
return in CodeIgniter?
The row_array()
and row()
will return only one row. Use result_array()
or result()
if you want to fetch multiple rows. See result_array()
Change $row = $query->row_array();
to $row = $query->result_array();