我有两个函数使用post方法。它们工作得很好。但问题是我不能同时使用这两种工具。如何解决这个问题?
function search_keyword()
{
$keyword = $this->input->post('keyword');
$this->data['result'] = $this->mymodel->search($keyword);
$this->twig->display('home.html', $this->data);
}
function genarate_csv(){
$pro_id = $this->input->post('keyword');
$this->data['re'] = $this->csv->ExportCSV($pro_id);
}
你可以试试这个方法
function search_keyword()
{
$keyword = $this->input->post('keyword');
$this->data['result'] = $this->mymodel->search($keyword);
$this->data['re'] = $this->genarate_csv($keyword);
$this->twig->display('home.html', $this->data);
}
function genarate_csv($keyword){
$re = $this->csv->ExportCSV($keyword);
return $re
}
try this
function search_keyword()
{
$keyword = $this->input->post('keyword');
$this->data['result'] = $this->mymodel->search($keyword);
$this->data['re'] = $this->csv->ExportCSV($keyword);
$this->twig->display('home.html', $this->data);
}
你可以在同一个函数中做
buhaaaaa haaaa....我解决了我的问题。我用治疗来解决我的问题。我想这会帮助像我这样的新手。
function __construct()
{
parent::__construct();
$this->load->model('mymodel');
$this->load->model('csv');
session_start();
$this->load->library('session');
}
public function search_keyword($key = "")
{
$keyword = $this->input->post('keyword');
$this->data['result'] = $this->mymodel->search($keyword);
$_SESSION[$key] = $keyword;
$this->twig->display('home.html', $this->data);
}
public function download($key = ""){
//print_r($_SESSION[$key]);
$keyword = $_SESSION[$key] ;
//print_r($keyword);
$this->data = $this->csv->ExportCSV($keyword);
$this->session->unset_userdata($keyword);
//$this->twig->display('home.html', $this->data);
}