I want to get list of email addresses from the database, what I have tried are here:
In my model:
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:
function get_email_address($search_by, $search_field) {
$recipients = $this->company_model->get_email_address_by_sector($search_by, $search_field);
print_r($recipients);
}
There are 2 records, and must be show both of them. But it shows the first record only. Is there any wrong in my code? Thank you.
row_array()
returns the first row only. If you want all the records to be returned, use result_array()
instead
$result = $query->result_array();
return $result;
$row = $query->row_array(); // it will only one row.
use result_array()
$row = $query->result_array();// it will return all rows
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With