Im getting a list from my database with the following (in my controller):
$view["interactions"] = $this->interacties->getInteractionsId($id);
This gives an array with everything in my database in the table 'interactions'.
Im posting this to my view with the following foreach loop:
<?php if($interactions): ?>
<?php foreach($interactions as $interaction): ?>
<tr class="gradeX">
<td><a href="<?=site_url('interactie/single/'.$interaction['id'])?>"><?=$interaction['datum']?></a></td>
<td><?=$interaction['gebruikers_id']?></td>
<td><?=$interaction['gesproken_met']?></td>
<td><?=$interaction['interactie']?></td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<p>Geen interacties</p>
<?php endif; ?>
This works fine, but now I want to change the $interaction['gebruikers_id']
to a name which is in my 'users' table which is called 'naam'. Normaly I would get the id and use another get function. But because this is in a foreach loop I'm not sure how to do this.
This is the function in the Model:
public function getInteractionsId($id) {
$this->db->select('*');
$this->db->where('bedrijf_id', $id);
$query = $this->db->get('interacties');
return $query->num_rows() > 0 ? $query-> result_array() : FALSE;
}