CodeIgniter Forums
Very Simple Issue I cant solve - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Very Simple Issue I cant solve (/showthread.php?tid=24628)



Very Simple Issue I cant solve - El Forum - 11-14-2009

[eluser]GamingFusion[/eluser]
I want the home page to displays the welcome message set in the info table of the database. Buts its not. why?

Model
Code:
function getInfo()
    {
        $query = $this->db->get('info');
        
        return $query->row();
    }

Controller (its doing other stuff just look at the last data entry(query))
Code:
function index()
    {            
    
    $is_logged_in = $this->session->userdata('isLoggedIn');
        
        if (!isset($is_logged_in) || $is_logged_in != TRUE)
        {
            $data['title'] = 'Theater 311';
            $data['heading'] = 'Welcome to Theater 311';
            $data['content'] = 'index';
            $data['css'] = 'site';
            $data['query'] = $this->database->getInfo();
        
            $this->load->view('includes/templates', $data);
        }
        else
        {
            $data['title'] = 'Theater 311';
            $data['heading'] = 'Welcome to Theater 311';
            $data['content'] = 'index';
            $data['css'] = 'site';
            $data['isLoggedIn'] = $this->session->userdata('isLoggedIn');
            $data['query'] = $this->database->getInfo();
        
            $this->load->view('includes/templates', $data);
        
        }
    }

View
Code:
<h1>&lt;?=$heading?&gt;</h1>
<p&lt;?=$this->typography->nl2br_except_pre($query->welcome)?&gt;</p>



Very Simple Issue I cant solve - El Forum - 11-14-2009

[eluser]The Casual Bot[/eluser]
Hey there,

you need to load your model

Code:
$this->load->model('getInfo');

then change

Code:
$data['query'] = $this->database->getInfo();

to

Code:
$data['query'] = $this->modelname->getInfo();

hope it helps

try here to

http://ellislab.com/codeigniter/user-guide/general/models.html


Very Simple Issue I cant solve - El Forum - 11-15-2009

[eluser]Maurice Calhoun[/eluser]
Sorry, but I had to do this.

Code:
function index()
    {            
    
            $data['title'] = 'Theater 311';
            $data['heading'] = 'Welcome to Theater 311';
            $data['content'] = 'index';
            $data['css'] = 'site';
            $data['isLoggedIn'] = $this->session->userdata('isLoggedIn');
            $data['query'] = $this->modelname->getInfo();
        
            $this->load->view('includes/templates', $data);
        
    }