Thanks both Phil Sturgeon & andrewtheandroid for your valuable time and replies.
andrewtheandroid, i understood your codes and it do work for me i changed it a bit.
I do the second query with the first queries result and it working.
I have the following Models::
function getCategory()
{
$query = $this->db->get_where('trainings_category', array('cat_status' => '1'));
return $query->result();
}
function getTrainingsName($id)
{
$query = $this->db->get_where('trainings_name', array('training_cat_id' =>$id,'training_title_status' => '1'));
return $query->result();
}
And the following view i created to show the accordion menu.
<div id="basic-accordian" >
<!--Parent of the Accordion-->
<!--Start of each accordion item-->
<?php foreach($cat_list as $t_cat): ?>
<div id="<?= $t_cat->cat_id ?>-header" class="accordion_headings" ><?= $t_cat->cat_name ?></div>
<!--Heading of the accordion ( clicked to show n hide ) -->
<!--Prefix of heading (the DIV above this) and content (the DIV below this) to be same... eg. foo-header & foo-content-->
<div id="<?= $t_cat->cat_id ?>-content">
<!--DIV which show/hide on click of header-->
<!--This DIV is for inline styling like padding...-->
<? $training_name_query = $this->Accordion_model->getTrainingsName($t_cat->cat_id);?>
<?php foreach($training_name_query as $t_name): ?>
<div class="accordion_child"><a href="#"></a>
<div>
<div class="A_menu_item"><?= $t_name->training_title?></div>
</div>
</div>
<?php endforeach ?>
</div>
<!--End of each accordion item-->
<!--Start of each accordion item-->
<?php endforeach ?>
<!--End of each accordion item-->
</div>
=> If the above structure ok?
Thanks.
Shahidul