我有这个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));
}
}
我的主要观点是starview.php。我可以使用div并将特定负载定位到特定div内的视图吗?我怎么能这样做?
谢谢
答案 0 :(得分:0)
请说出您的 startview 视图...
//Your question goes here
//Answer part
<?php if($this->input->post()):
echo $answer_view_data
endif; ?>
在function 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));
}
}