Welcome Guest, Not a member yet? Register   Sign In
Attempting my 1st model... but beginning to struggle!
#11

[eluser]InsiteFX[/eluser]
Code:
//Select Next Comp from DB for footer
    $this->load->model('NextComp');
    $NextComp = array(); // rename this to something else it's the same name as your model
    if($query = $this->NextComp->index()) // this thinks your calling your $NextComp array!
    {
        $NextComp['results'] = $query;
    }
    
    //Loads view & passes $data and $NextComp
    $this->load->view('template', $data, $NextComp);
    }

Enjoy
InsiteFX
#12

[eluser]JamesTaylor[/eluser]
Thanks for the latest replys.

Alboyd, all the posts so far have been helpful and each has given me a new insight to something.

I suppose in a way this is a bit of a strange post, as i am working on test project and the code i am providing are real examples that i am working on. However, i don't just want to copy someones code and say its working!

The real purpose of this thread for me is try and get my head around the process of requesting the data and moving it between the model, controller and view in a reasonably good manner! I feel i am getting closer to this as people have provided reponses to the thread - yours and InsiteFX latest posts have giving me more insight again, i will be going away and playing with the code provided so i understand what is actually happening.

Quote:Say you have $results like you have shown. Personally - most of the time unless I have to manipulate the data in the $results - I’ll just send $results to the view and then if you want to present multiple rows I’ll do it like this:

How do you pass $results to the view? Would it be as:

Code:
$this->load->view('template', $data, $results);

so is it possible to pass as many variables / arrays to the view as required by adding it the $this->load->view(); code as above? This is what i was attempting to do originally but without success, however it appears from InsiteFX post that i wasn't to far wrong in principle, just that i had conflicts in the code.

Anyway all the posts so far have been much appreciated and hopefully the penny will drop soon!

Thanks

James




Theme © iAndrew 2016 - Forum software by © MyBB