I have a page that displays posts and I want to get the name of the author next to each post. There is a DB table for pages (with a column called title and author) and one for authors (with a column called id and author).
Control
function pages() { // QUERIES $pages_query = $this->db->get('table_pages'); $authors_query = $this->db->get_where('table_authors', array('id =' => $row->author)); // DATA $data['pages'] = $pages_query; $data['authors'] = $authors_query; // CREATE $this->load->view('admin_pages', $data); } View
<? foreach ($pages->result() as $row): ?> Title: <?=$row->title?>, by <?=$authors['id']?><br /> <? endforeach; ?> I think my issue is in calling the author based on the id in control but I just can't seem to figure it out.