我需要创建一个输入类型=“ radio”,它将进行多次民意调查,并将根据所选选项将答案存储在数据库中。
如何将所有轮询响应插入同一张表中。
下面是带有收音机的HTML代码。
<tr>
<td>
<div class="radio">
<input type="hidden" id="questao" name="questao" value="84">
<label><input type="radio" value="291" name="84">Ótimo</label>
<label><input type="radio" value="292" name="84">Bom</label>
<label><input type="radio" value="293" name="84">Regular</label>
<label><input type="radio" value="294" name="84">Fraco</label>
</div>
</td>
</tr>
<tr>
<td>
<div class="radio">
<input type="hidden" id="85" name="85" value="85">
<label><input type="radio" value="295" name="85">Ótima</label>
<label><input type="radio" value="296" name="85">Boa</label>
<label><input type="radio" value="297" name="85">Regular</label>
<label><input type="radio" value="298" name="85">Fraca</label>
</div>
</td>
</tr>
<tr>
<td>
<div class="radio">
<input type="hidden" id="86" name="86" value="86">
<label><input type="radio" value="299" name="86">Ótimo</label>
<label><input type="radio" value="300" name="86">Bom</label>
<label><input type="radio" value="301" name="86">Regular</label>
<label><input type="radio" value="302" name="86">Fraco</label>
</div>
</td>
</tr>
<tr>
<td>
<div class="radio">
<input type="hidden" id="87" name="87" value="87">
<label><input type="radio" value="303" name="87">Ótimo</label>
<label><input type="radio" value="304" name="87">Bom</label>
<label><input type="radio" value="305" name="87">Regular</label>
<label><input type="radio" value="306" name="87">Fraco</label>
</div>
</td>
</tr>
在控制器内部的laravel中创建的功能下方
public function enviando(Request $request)
{
$date = date("Y-m-d h:m:s");
$pegar_ip = $_SERVER["REMOTE_ADDR"];
if($_POST = '84'){
$questao_id = '84';
}
if($_POST = '85'){
$questao_id = '85';
}
if($_POST = '86'){
$questao_id = '86';
}
if($_POST = '87'){
$questao_id = '87';
}
DB::table('eventos_avaliacoes_participantes')
->insert(['avaliacao_id' => "2",
'nome' => $request->input('nome'),
'email' => $request->input('email'),
'sexo' => $request->input('sexo'),
'comentarios' => $request->input('comentarioevento'),
'ip' => $pegar_ip,
'created' => $date]);
$id = '171';
$opcao = $request->input('84');
DB::table('eventos_avaliacoes_participantes_opcoes')
->insert(['opcao_id' => $opcao,
'questao_id' => $questao_id,
'participante_id' => $id+1]);
return redirect('sucesso');
}