I have two functions in my controller like this.
function search_keyword()
{
$keyword = $this->input->post('keyword');
$this->data['result'] = $this->mymodel->search($keyword);
//print_r($this->data);
//$pro_id = [];
foreach($this->data['result'] as $key => $val){
$pro_id[] = $val->product_id;
}
print_r($pro_id);
$this->download_function();
$this->twig->display('home.html', $this->data);
}
function download_function()
{
//print_r($keyword);
$this->data['re'] = $this->csv->ExportCSV($keyword);
$this->twig->display('home.html', $this->data);
}
I want to pass pro_id variable to download_function from search_keyword funtion.please help me to do this.
this is my model
function ExportCSV($pro_id)
{
//print_r($keyword);
$this->load->dbutil();
$this->load->helper('file');
$this->load->helper('download');
$delimiter = ",";
$newline = "\r\n";
$filename = "filename_you_wish.csv";
$query = "SELECT * FROM products WHERE product_id LIKE '%$pro_id%'";
$result = $this->db->query($query);
$data = $this->dbutil->csv_from_result($result, $delimiter, $newline);
force_download($filename, $data);
}
$this->download_function($pro_id);$this->download_function(VARIABLE);and getting usingfunction download_function(VARIABLE)