I cannot use result() or result_array() on a variable that has been passed to the vie - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: I cannot use result() or result_array() on a variable that has been passed to the vie (/showthread.php?tid=68453) |
I cannot use result() or result_array() on a variable that has been passed to the vie - desbest - 07-12-2017 Say I have this code. debate.php Code: <?php And inside the _comments.php view there's Code: <?php What happens is that the content from the database shows in the debate.php file, but not in the _comments.php file, when it should as I'm dealing with the same variable. What is going on? RE: I cannot use result() or result_array() on a variable that has been passed to the vie - krystian2160 - 07-12-2017 Do $this->load->view('_comments', array('datax' => $datax)); and in view var_dump($datax); will work. read the documentation RE: I cannot use result() or result_array() on a variable that has been passed to the vie - Martin7483 - 07-13-2017 If that is the code your are using, then you are overwriting the $approval variable. PHP Code: $approval= $this->db->get('posts'); Change it to this and it should work PHP Code: $query = $this->db->get('posts'); // Renamed $approval to $query RE: I cannot use result() or result_array() on a variable that has been passed to the vie - rtenny - 07-13-2017 Should it in the view not be: <?php foreach ($traffic as $approval) { echo $approval->content; } ?> the ->result() is for a database object not an array |