bigil 0 Newbie Poster

i want to list car category name and car details in a single page

but the result is car details are same for every category….
can anyone help me .....

thanks in advance

controller

function index()
    {
        
    $fleets = $this->Fleets_model->select_fleets();
    $this->data['fleets'] = $fleets;
        foreach($fleets as $row)
        {
         $cid = $row->category_id;
         $this->data['listefleets'] = $this->Fleets_model->list_fleets($cid);
        }
    $this->load->view('fleets',$this->data);    
    }

model

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();
   }
function list_fleets($cid)
   {
   $this->db->where('category_id',$cid);
   $result_product = $this->db->get('cars');
   return $result_product->result();
   }

view

<?php foreach($fleets as $row)
 {
 ?>
   <?php echo $row->category_name;?>
       
     <?php foreach($listefleets as $row)
     {
     ?>
         <?php echo $row->car_name;?>
     <?php
      }
     ?>
}
?>