[eluser]Unknown[/eluser]
** 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

) and used the function below:
Model
Code:
function fetch_cats()
{
//select the categories from the database and order by cat name
$this->db->select('CatID,CatName');
$this->db->order_by('CatName');
$query=$this->db->get('PageCats');
if($query->num_rows() > 0)
{
return $query->result();
}
else
{
return FALSE;
}
}
In the
controller I called it as such:
Code:
//* load the model to fetch the invader categories
$this->load->model('CatList','CList');
$this->data['Cats'] = $this->CList->fetch_cats();
//load view invaders/index and attach model data to it
$this->load->view('getcats/index', $this->data);
View
Code:
<?php
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
Thanks in advance to anyone that can help.