Welcome Guest, Not a member yet? Register   Sign In
Model function references not recognized
#2

[eluser]Derek Allard[/eluser]
Hi Frank. Welcome to CodeIgniter.

I think its just a matter of getting comfortable with how models work for you. Try this. In your model, change it from "echo" to "return", which just means "hand this off to something else".

Now I'm just going to flip the order of what you've got here a bit. I'm going to load the model first (you need to load it before you reference it), and then I'm going to store the results of a the hello world function into something I can pass to the view, in this case an array called "data".

Code:
<?php

class Welcome extends Controller {

        function Welcome()
        {
                parent::Controller();
        }

        function index()
        {
                $this->load->model('Welcome_model');
                // notice how I'm storing this as "my_message" in an array called data?
                $data['my_message'] = $this->Welcome_model->helloWorld();
                // now when we load the view, we make sure the data array goes into it
                $this->load->view('welcome_message', $data);
        }
}
?>

Now in your welcome_message view, put this
Code:
<?php echo $my_message;?>


Messages In This Thread
Model function references not recognized - by El Forum - 01-01-2008, 04:24 PM
Model function references not recognized - by El Forum - 01-01-2008, 04:53 PM
Model function references not recognized - by El Forum - 01-01-2008, 07:48 PM
Model function references not recognized - by El Forum - 01-01-2008, 10:28 PM
Model function references not recognized - by El Forum - 01-17-2008, 09:09 AM
Model function references not recognized - by El Forum - 01-17-2008, 09:26 AM
Model function references not recognized - by El Forum - 01-17-2008, 09:34 AM
Model function references not recognized - by El Forum - 01-17-2008, 09:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB