Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Passing values from one function to another in a model?

** Admin please move to code discussion forum, my apologies for wrong section **

Ok first off I am totally new to CI and php and was stoked when I was able to actually get the controller, model and view to all talk to each other and actually show data.

I have one table (CatList) that list the names of categories with a CatID field. I have a 2nd table (PageDetails) with more details and a CatID field that relates to the CatList.CatID field.

What I want to do is list the headings from the CatList table with a list of the pages from the PageDetails table that are listed with the same CatID.

I was able to get the headings to list (my first success with working with data Smile ) and used the function below:

function fetch_cats()
//select the categories from the database and order by cat name
    if($query->num_rows() > 0)
           return $query->result();
        return FALSE;
In the controller I called it as such:
//* load the model to fetch the invader categories
    $this->data['Cats'] = $this->CList->fetch_cats();

    //load view invaders/index and attach model data to it
    $this->load->view('getcats/index', $this->data);

    foreach ($Cats as $Cat)
    echo('<h1>' . $Cat . '</h1>');

Now what I can figure out for the life of me is how to script a second function (and believe me I tried many combinations) to call and list the pages for each category heading according to its CatID. I am stuck on how to pass values between functions in the model.

I am a cold fusion developer and this is my 2nd day attempting to learn this framework (and php) so please bare with me as I realize this may be a simple question to most people here.....got to learn somewhere Smile

Thanks in advance to anyone that can help.

Messages In This Thread
[SOLVED] Passing values from one function to another in a model? - by El Forum - 04-19-2010, 12:47 PM

Theme © iAndrew 2016 - Forum software by © MyBB