所以我用mvc在codeigniter中做了一个小测试,到目前为止我有一个查询,从perguntas表得到问题,从resposta表得到答案。
所以我做了一个有10个问题的小测验,每个问题在视图中单独显示,问题是每次我点击next,我都会得到一个重复的问题,在同一个测验中已经回答了,所以基本上我´我不断有问题。
你知道如何解决这个问题而不重复同样的问题吗?
blockquote这是我的模型:
$query = $this->db->query("SELECT PERGUNTAS.ID_PERGUNTA, PERGUNTAS.NOME_PERGUNTA, RESPOSTA.RESPOSTACERTA, RESPOSTA.RESPOSTAERRADA1, RESPOSTA.RESPOSTAERRADA2, RESPOSTA.RESPOSTAERRADA3
FROM PERGUNTAS
INNER JOIN RESPOSTA
WHERE PERGUNTAS.ID_PERGUNTA = RESPOSTA.ID_RESPOSTA
AND PERGUNTAS.TEMA = 'Futebol'
ORDER BY Rand() LIMIT 1");
return $query->result();
这是我的控制器
public function IniciarJogoFutsal()
{
if($this->session->userdata['logged_in']['id_util'])
{
if($this->session->userdata['logged_in']['isadmin'] !=0)
{
$this->load->model('Jogo_model');
$data['list'] = $this->Jogo_model->BuscarPerguntasRespostasFutsal();
$this->load->view('header_admin');
$this->load->view('jogo_futsal', $data);
}
if($this->session->userdata['logged_in']['isadmin'] !=1)
{
$this->load->model('Jogo_model');
$data['list'] = $this->Jogo_model->BuscarPerguntasRespostasFutsal();
$this->load->view('header_user');
$this->load->view('jogo_futsal', $data);
}
}
else
{
redirect('Login/index');
}
}
这是我观点的一部分 jogo_futsal
当我点击“下一个问题”时,我会回显问题,刷新页面
<?php foreach($list as $quiz): ?>
<label style="color: #ffffff; word-wrap: break-word; transform: skew(20deg);font-weight: 900; text-shadow: 1px 0 #ffffff;"><?php echo $quiz->NOME_PERGUNTA;?> </label>
<?php endforeach ?>
暂无答案!
目前还没有任何答案,快来回答吧!