0
I have the following model:
function validarQuestionario()
{
if(is_array($this->input->post('resposta[]')) || is_object($this->input->post('resposta[]')))
{
foreach ($this->input->post('resposta[]') as $single_resp)
{
foreach ($this->input->post('idMarcacao[]') as $single_id)
{
$data['respostaAluno'] = $single_resp;
$data['idMarcacao'] = $single_id;
$this->db->insert('tbdquestionario', $data);
}
}
}
}
Instead of being recorded 10 lines that would be the correct value, is being logged 100 lines in the bank.
if the answer[] is the event[] is 10 each 10 x 10 = 100 correct?
– novic
Exact, but how could I recover the data to do Insert without the foreach?
– igorarmelin
Just to confirm, are you using Codeigniter? By the syntax it seems to be it, so I entered the tag, but if it is not I can remove it.
– Woss
Will you do the
for
normalfor($i = 0; $i < count(resposta[]);$i++) { resposta[$i] ... // assim por diante }
– novic
@Woss, it’s Codeigniter yes!!
– igorarmelin