0
I have a test in my database, and each question has its answers (Right, Wrong1, Wrong2, Wrong3). I can list the questions in different forms, but my problem is to list the answers in radiobuttons
with different names. Since if everyone has the same name, when selecting one, the others will be disregarded.
<?php
$instS='Select * from perguntas';
$query = mysqli_query($conn,$instS);
while ($row = mysqli_fetch_assoc ($query))
{echo"<br>";
echo"<center><fieldset style='border:solid; width:500px;'>";
echo" <legend style='background: #FF9; width:150px; border: solid 1px black;
-webkit-border-radius: 8px; -moz-border-radius: 8px;
border-radius: 8px; padding: 6px;'> Questão: ".$row['idPergunta']."";echo"</legend>";
echo "<center> <h4><b> Pergunta: </h4></center></b>";
echo"<center>"
.$row['textoPerguntas'].""; //Buscar a pergunta a base de dados
echo"<center>";
echo "<center><h4><b> Resposta: </h4></center></b>";
// queria aqui buscar as respostas, mas de modo a que a cada set de 4 perguntas, os nomes das radiobuttons fossem alterados (RespostaCerta,Errada1,Errada2,Errada3 name=questao1),
(RespostaCerta,Errada1,Errada2,Errada3 name=questao2), etc, consoante ao numero de perguntas que existe
echo "<input type='radio' name='dd' id='resposta'>";
echo "<br>";
echo "<br>";
?>
You cannot use: question_id_resposta_id?
– Marcus Becker
what do you mean by that ?
– Paulo
From what I understand, the answers are getting duplicated, resp_1, resp_2, correct? Example:
<input type='radio' name='perg_1_resp_1' />
– Marcus Becker
Yes exact. And I was wondering if there’s a way I can automatically assign " name=pertg1_rest1", "name=pertg1_rest2", "name=pertg1_rest3", "name=pertg2_rest1" and so on
– Paulo
as I am removing the answers and questions from the database
– Paulo
But if you put them with the same
name
you will be able to dial more and a radio button, not?– LocalHost