-1
$sql = "SELECT * FROM perguntas ORDER BY id_pergunta";
$execsql = mysqli_query($conn, $sql) or die("Erro");
while($row = mysqli_fetch_array($execsql)){
# code...
$IdPergunta = $row['id_pergunta'];
$p = $row['pergunta'];
$ra = $row['respostaa'];
$rb = $row['respostab'];
$rc = $row['respostac'];
$rd = $row['respostad'];
$vp = $row['valor_pergunta'];
}
echo '<?xml version="1.0" encoding="UTF-8" ?>';
echo '<root>';
echo '<Pergunta id="IdPergunta">' . $IdPergunta . '</Pergunta>';
echo '<Pergunta id="ValorPergunta">' . $vp . '</Pergunta>';
echo '<Pergunta id="Pergunta">' . $p . '</Pergunta>';
echo '<Pergunta id="RespostaA">' . $ra . '</Pergunta>';
echo '<Pergunta id="RespostaB">' . $rb . '</Pergunta>';
echo '<Pergunta id="RespostaC">' . $rc . '</Pergunta>';
echo '<Pergunta id="RespostaD">' . $rd . '</Pergunta>';
echo '</root>';
?>```
Only the last dice passed by will appear
while
in your case. In order for you to get all the data, you will have to put this whole block ofecho
inside your while, otherwise it will not print all the data.– Jakson Fischer
Continue on 1° question
– João victor
I don’t understand very well, but you mean repeat the
echo
?– Lennon S. Bueno
I have to vote to close because I can’t understand the question. You have to be clearer, if you have difficulties in formulating questions comment on the code what to do.
– Augusto Vasques
@Joãovictor, if only one die is appearing when you put the echo inside the
while
, it is probably because it is returning only one data even, otherwise it will make a looping and will print all the results...– Jakson Fischer