将两个数组值从控件提供给我的视图页面

时间:2019-05-25 18:39:56

标签: php codeigniter model-view-controller

从控制器向我的视图页面提供两个数组值

    $data2=$this->input->POST();

    if($this->quiz_mod->login($data2))
    {
    $qus= $this->quiz_mod->get_data();
    $ans= $this->quiz_mod->get_data2();
    }

2 个答案:

答案 0 :(得分:2)

 $data2=$this->input->POST();

if($this->quiz_mod->login($data2))
{

$qus= $this->quiz_mod->get_data();
$ans= $this->quiz_mod->get_data2();

$data['qus'] = $qus;
$data['ans'] = $ans;

$this->load->view('VIEW_NAME_HERE',$data);
// in view get data in these array $qus and $ans 

 }

答案 1 :(得分:0)

第一件事是,如果要传递多个数组以进行查看,则应在​​控制器中执行类似的操作

$data=array();
$data['qus']=$this->model_name->function_name(); // query for qus
$data['ans']=$this->model_name->function_name(); // query for ans
$this->load->view('view_name',$data);