I am new to codeigniter. Currently I am working on a small project as practice and I am trying to display data of two tables on the same web page.
I tried to use$this->db->join();
in codeigniter but it does not work for me. I was wondering is there other options that I can explore of displaying two table data on a same web page?
I am also posting my join method that I have tried - maybe you can tell me I did something wrong?
model
$this->db->select('tblanswers.*,credentials.*');
$this->db->from('tblanswers');
$this->db->join('credentials', 'tblanswers.answerid = credentials.cid', 'left');
$query = $this->db->get();
return $query->result();
The problem with this join function I have that it only displays one table but not the other. I used the print_r($data['query']); die()
to checked this it only returns the tblanswer not both.
EDIT
Table structure:
credentials
+--------------+------+-------------+-------+-------+
| cid(PRIMARY) | name | second_name | phone | email |
+--------------+------+-------------+-------+-------+
tblanswers
+-------------------+--------+------------+---------+---------+---------+
| answerid(PRIMARY) | userid | questionid | answerA | answerB | answerC |
+-------------------+--------+------------+---------+---------+---------+