Welcome Guest, Not a member yet? Register   Sign In
from controller to view , how?
#1

[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');
        }        
    }
#2

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

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

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

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

[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
#6

[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?




Theme © iAndrew 2016 - Forum software by © MyBB