[eluser]cideveloper[/eluser]
Controller
Code:
function index() {
$build_array = array();
$fleets = $this->Fleets_model->select_fleets();
foreach($fleets as $row){
$build_array[] = array (
'fleets_array' => $row,
'listefleets_array' => $this->Fleets_model->list_fleets($row['category_id'])
);
}
$data = array (
'meow' => $build_array
);
$this->load->view('fleets',$data);
}
Models - Change it to return Array
Code:
function select_fleets() {
$this->db->select('car_category.category_name, car_category.category_id, car_category.details');
$this->db->from('car_category');
$this->db->join('cars', 'cars.category_id = car_category.category_id');
$result_product = $this->db->get();
return $result_product->result_array();
}
function list_fleets($cid){
$this->db->where('category_id',$cid);
$result_product = $this->db->get('cars');
return $result_product->result_array();
}
View
Code:
<div>
<?php
foreach ($meow as $crow)
{
echo $crow['fleets_array']['category_name'] . '<br />' . chr(10);
foreach ($crow['listefleets_array'] as $lrow)
{
echo ' ' . $lrow['car_name'] . '<br />' . chr(10);
}
}
?>
</div>