Get value from joined tables, Codeigniter
I'm trying to get and display the data from joined tables but I can't get anything in return. I reference this and it worked on my other function, but when I tried it again on a different function, I can't get any results.
Here's the Model:
public function viewReview($id)
{
$this->db->select('clients.firstname, clients.lastname, packages.title, rate_review.review, rate_review.date_created');
$this->db->where('rate_review.id', $id);
$this->db->join('clients', 'clients.id = rate_review.user_id');
$this->db->join('packages', 'rate_review.package_id = packages.id');
$this->db->from('rate_review');
$query = $this->db->get();
return $query->row_array();
}
Controller:
public function view_review($id)
{
$data['title'] = 'Rate & Reviews';
$data['review'] = $this->Admin_model->viewReview($id);
$this->load->view('../admin/template/admin_header');
$this->load->view('../admin/template/admin_topnav');
$this->load->view('../admin/template/admin_sidebar');
$this->load->view('../admin/rate_review/view', $data);
$this->load->view('../admin/template/admin_footer');
}
View:
<div class="card-body">
<p>User:
<?php echo $review['firstname'].' '. $review['lastname']; ?>
</p>
<p>Package:
<?php echo $review['title']; ?>
</p>
<div class="m-2">
<pre class="border-2"><?php echo $review['review']; ?></pre>
<br>
<span class="mt-2"><?php echo $review['date_created']; ?></span>
</div>
</div>
Comments
Post a Comment