Guest User

Untitled

a guest
Nov 28th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. <?php foreach ($query as $row): ?>
  2.  
  3. <?php echo $row->answerA;?><br>
  4. <?php echo $row->answerB;?><br>
  5. <?php echo $row->answerC;?><br>
  6. <?php echo $row->comment;?><br>
  7. <?php echo $row->name; ?>
  8.  
  9. <?php endforeach; ?>
  10.  
  11. function getall() {
  12.  
  13. $this->load->model('result_model');
  14. $data['query'] = $this->result_model->result_getall();
  15. // print_r($data['query']);
  16. // die();
  17. $this->load->view('result_view', $data);
  18.  
  19. }
  20.  
  21. function result_getall() {
  22.  
  23. $this->db->select('tblanswers.*,credentials.*');
  24. $this->db->from('tblanswers');
  25. $this->db->join('credentials', 'tblanswers.answerid = credentials.cid', 'right outer');
  26. $query = $this->db->get();
  27. return $query->result();
  28.  
  29. }
  30.  
  31. print_r($data['query']);
  32. die();
  33.  
  34. 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 ) )
  35.  
  36. $this->db->join('credentials', 'tblanswers.answerid = credentials.cid');
  37.  
  38. $this->db->join('credentials', 'tblanswers.answerid = credentials.cid', 'inner');
  39.  
  40. $this->db->join('credentials', 'tblanswers.answerid = credentials.cid', 'outer');
  41. $query = $this->db->get('tblanswers');
  42. return $query->result();
  43.  
  44. function result_getall(){
  45.  
  46. // if you want to query your primary data from the table 'tblanswers',
  47. $this->db->select('a.*,b.*'); <-- select what you might want to select
  48. $this->db->from('tblanswers a');
  49. $this->db->join('credentials b', 'b.cid = a.answerid', 'left');
  50. $query = $this->db->get();
  51. return $query->result();
  52.  
  53. // if you want to query your primary data from the table 'credentials',
  54.  
  55. $this->db->select('a.*,b.*'); <-- select what you might want to select
  56. $this->db->from('credentials a');
  57. $this->db->join('tblanswers b', 'b.answerid = a.cid', 'left');
  58. $query = $this->db->get();
  59. return $query->result();
  60.  
  61. }
Add Comment
Please, Sign In to add comment