[eluser]AFRC[/eluser]
Hi,
I have a model with two queries:
Code:
function listCategories()
{
$result=$this->db->query("select * from table")->result();
return $result;
}
function listSubCategories($var)
{
$result=$this->db->query("select * from table where field=$var")->result();
return $result;
}
Then i call the first function on my controller:
Code:
$data['rows']=$this->my_model->listCategories();
The problem is: now i need to call the second function (
listSubCategories()) and the
$var that i need to pass to it, is a field from the database which is returned by the
listCategories() function.
The idea was doing something like (in the view):
Code:
foreach ($categories as $category) {
echo '<h1>'.$category->title.'</h1>';
foreach ($subcategories as $subcategory) {
echo '<h2>'.$subcategory->title.'</h2>';
}
}
What's the best way to handle a situation like this?
Thanks in advance.