Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php foreach ($query as $row): ?>
- <?php echo $row->answerA;?><br>
- <?php echo $row->answerB;?><br>
- <?php echo $row->answerC;?><br>
- <?php echo $row->comment;?><br>
- <?php echo $row->name; ?>
- <?php endforeach; ?>
- function getall() {
- $this->load->model('result_model');
- $data['query'] = $this->result_model->result_getall();
- // print_r($data['query']);
- // die();
- $this->load->view('result_view', $data);
- }
- function result_getall() {
- $this->db->select('tblanswers.*,credentials.*');
- $this->db->from('tblanswers');
- $this->db->join('credentials', 'tblanswers.answerid = credentials.cid', 'right outer');
- $query = $this->db->get();
- return $query->result();
- }
- print_r($data['query']);
- die();
- Array ( [0] => stdClass Object ( [answerid] => [userid] => [questionid] => [answerA] => [answerB] => [answerC] => [comment] => [cid] => 83 [name] => Edvinas [second_name] => liutvaits [phone] => [email] => ledvinas@yahoo.ie ) [1] => stdClass Object ( [answerid] => [userid] => [questionid] => [answerA] => [answerB] => [answerC] => [comment] => [cid] => 84 [name] => Edvinas [second_name] => liutvaits [phone] => [email] => ledvinas@yahoo.ie ) [2] => stdClass Object ( [answerid] => [userid] => [questionid] => [answerA] => [answerB] => [answerC] => [comment] => [cid] => 85 [name] => Edvinas [second_name] => Liutvaitis [phone] => [email] => ledvinas@yahoo.ie ) [3] => stdClass Object ( [answerid] => [userid] => [questionid] => [answerA] => [answerB] => [answerC] => [comment] => [cid] => 86 [name] => EdvinasQ [second_name] => LiutvaitisQ [phone] => 12345678 [email] => ledvinas@yahoo.ie ) [4] => stdClass Object ( [answerid] => [userid] => [questionid] => [answerA] => [answerB] => [answerC] => [comment] => [cid] => 87 [name] => Edvinas [second_name] => Liutvaitis [phone] => 123456 [email] => ledvinas@yahoo.ie ) )
- $this->db->join('credentials', 'tblanswers.answerid = credentials.cid');
- $this->db->join('credentials', 'tblanswers.answerid = credentials.cid', 'inner');
- $this->db->join('credentials', 'tblanswers.answerid = credentials.cid', 'outer');
- $query = $this->db->get('tblanswers');
- return $query->result();
- function result_getall(){
- // if you want to query your primary data from the table 'tblanswers',
- $this->db->select('a.*,b.*'); <-- select what you might want to select
- $this->db->from('tblanswers a');
- $this->db->join('credentials b', 'b.cid = a.answerid', 'left');
- $query = $this->db->get();
- return $query->result();
- // if you want to query your primary data from the table 'credentials',
- $this->db->select('a.*,b.*'); <-- select what you might want to select
- $this->db->from('credentials a');
- $this->db->join('tblanswers b', 'b.answerid = a.cid', 'left');
- $query = $this->db->get();
- return $query->result();
- }
Add Comment
Please, Sign In to add comment