[eluser]codex[/eluser]
Ok guys,
this is probably a silly question, but I just can't see it (it's late and I had a bit of alcohol ;-) ).
I'm making a private messaging system and this part is where the new message is being inserted. See the loop below: $recipients is an array that holds the id's of the multiple receivers. What I want to do is take the array, query the db for the corresponding username, create a variable of the usernames and insert that together with the new message. The variable is just a simple string, example: 'jason, perry, luke, antoine'.
How do I write the loop to the variable?? Help is greatly appreciated!
Code:
foreach ($recipients as $recipient)
{
$this->db->select('user_name');
$this->db->where('user_id', $recipient);
$query = $this->db->get('users');
$user = $query->result_array();
$str = $user[0]['user_name'] .', '; // this is obviously not the way to do it
}