如何使用控制器中的查询在视图中生成表

I have a problem generating table using ci table.

I want to generate table using a query inside controller but the issue is the code...

echo $this->table->generate($query);

... from ci table, MUST BE inside the view.

I have a view called my_view.

I already made a query inside my controller.

my_controller.php

$data["all_jobs"] = $this->emp->get_all_filtered_candidate();

Got it!

You have to prepare the table inside the controller and model then put it inside an variable array to carry over to your view. Example.

Controller

public function index()
{ 
   $this->load->model('your_model');
   $data['generated_code'] = $this->your_model->get_table(); 
   $this->load->view('your_view', $data);
}

Model

public function get_table()
{
   $query = $this->db->get('your_table');
   return $this->table->generate($query);
}

View

echo $generated_code;