Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将其他数据加载到视图中_Php_Codeigniter_Model View Controller - Fatal编程技术网

Php 将其他数据加载到视图中

Php 将其他数据加载到视图中,php,codeigniter,model-view-controller,Php,Codeigniter,Model View Controller,我有一段PHP代码,我正在将一个测验加载到视图中。当我选择并提交答案时,视图将更改,只显示正确或错误的消息。 我试图实现的是,当点击提交按钮获得答案时,保留问题并在“是否正确”下显示。 这是我的代码: function guess() { $guess = $this->input->get('name',false); $personid = $this->input->get('id',false); if ($guess === null)

我有一段PHP代码,我正在将一个测验加载到视图中。当我选择并提交答案时,视图将更改,只显示正确或错误的消息。 我试图实现的是,当点击提交按钮获得答案时,保留问题并在“是否正确”下显示。 这是我的代码:

function guess()
{
    $guess = $this->input->get('name',false);
    $personid = $this->input->get('id',false);
    if ($guess === null) {

        $newguess['data'] = $this->Starmodel->getQuestion();
        $this->load->view('starview',$newguess);
    }
    else {
        $res= $this->Starmodel->isCorrectAnswer($personid,$guess);
        $person = $this->load->view('starview', array('iscorrect' => $res,
                                                      'name' => $guess));
         }     
}
我的主要视图是饥饿视图.php。我可以使用div并针对特定div中的特定加载视图吗?我该怎么做


谢谢

让我们说说你的startview视图

//Your question goes here



//Answer part
<?php if($this->input->post()): 
      echo $answer_view_data 
 endif; ?>

数据以相同的方式显示。我已经在显示答案“name”=>$guess
function guess()
{
    $guess = $this->input->get('name',false);
    $personid = $this->input->get('id',false);
    if ($guess === null) {

        $newguess['data'] = $this->Starmodel->getQuestion();
        $this->load->view('starview',$newguess);
    }
    else {
        $res= $this->Starmodel->isCorrectAnswer($personid,$guess);
        $answer_data = 'Sample answer data';
        $person = $this->load->view('starview', array('iscorrect' => $res,
                                                      'name' => $guess, 'answer_data' => $answer_data));
         }     
}