CodeIgniter Forums
from controller to view , how? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: from controller to view , how? (/thread-12565.html)



from controller to view , how? - El Forum - 10-23-2008

[eluser]JayArias[/eluser]
below is my controller , for the main page. How would i go buy adding the query to my VIEW cause if i put the query code in the view it screws up. ive tried several things.

Code:
<?php

    class Home extends Controller{
    
        function Home()
        {
            parent::controller();
        }
        function index()
        {
            
            $this->load->database('default');
            $fetch_news = $this->db->query("SELECT * FROM `news` WHERE `verified` = '1' ORDER BY `id` DESC");
            $news = $fetch_news->row_array();
            $this->load->view('default_view');
        }        
    }



from controller to view , how? - El Forum - 10-23-2008

[eluser]narkaT[/eluser]
from the documentation:

Code:
$data = array(
               'title' => 'My Title',
               'heading' => 'My Heading',
               'message' => 'My Message'
          );
$this->load->view('blogview', $data);



from controller to view , how? - El Forum - 10-23-2008

[eluser]Unknown[/eluser]
You should put that in model not controller.


from controller to view , how? - El Forum - 10-23-2008

[eluser]JayArias[/eluser]
Fatal error: Call to undefined method CI_Loader::modle() in C:\www\system\application\views\default_view.php on line 19


from controller to view , how? - El Forum - 10-23-2008

[eluser]Derek Allard[/eluser]
[quote author="Tego10122" date="1224813010"]Fatal error: Call to undefined method CI_Loader::modle() [/quote]
Try model() and not modle() Smile


from controller to view , how? - El Forum - 10-24-2008

[eluser]JayArias[/eluser]
[quote author="Srecko Micic" date="1224808905"]You should put that in model not controller.[/quote]

what should be placed there? , the whole query or just the array?