How can I extract the field: chat_id
from this array? I'm trying to put the chat_id in the id of a button in html.
Array
(
[0] => stdClass Object
(
[id] => 2
[first_name] => Armani
[last_name] => Dee
[contact_number] => 123456
[email_address] => hello@gmail.com
[home_address] =>
[username] => armani
[password] => 12345
[status] => 0
[email_confirmed] => 0
[chat_id] => 14
[admin_id] => 0
[customer_id] => 2
[partner_id] => 0
[timestamp] => 2018-06-15 22:38:24
[chat_exists] => 1
[reply_id] => 208
[message] => Hello
[timestamp_reply] => 2018-06-16 14:02:44
[chat_status] => 0
)
)
I got my output from my model:
public function chat_customer($enum)
{
$this->db->select('*');
$this->db->from('customer');
$this->db->order_by('timestamp','desc');
$this->db->where('customer.id',$enum);
$this->db->join('chat','chat.customer_id = customer.id','left');
$this->db->join('chat_reply', 'chat_reply.chat_id = chat.chat_id', 'left');
$query = $this->db->get();
return $query->result();
}
Then I retrieved it in my controller like this:
$customer_id = $this->input->get('message');
$this->load->model('Crud_model');
$data = $this->Crud_model->chat_customer($customer_id);
echo print_r($data);
I'm trying to print the 14 on the chat_id. Thank you for your help!