0
Hello, I’d like some help. And if you have any better ideas, you’re welcome to ;) Basically the idea is to search a question bank, randomly choose 5 of them and link them in the record of a candidate who will take this test.
<?php
require_once("conecta.php");
$nome = "Maria";
$query = "SELECT * FROM questoes ORDER BY RAND() limit 5";
$sql = mysqli_query($conexao, $query);
while ($perguntas = mysqli_fetch_array($sql)) {
echo $perguntas['id'];
}
$query2 = "INSERT INTO avaliacao (nome, q1, q2, q3, q4, q5)
VALUES ('maria', '{$perguntas['id']}', '6', '7', '8', '9')";
return mysqli_query($conexao, $query2);
?>
I have this bench of questions:
I would like to take these random questions and insert them into Q1,Q2, etc
Basically a different quiz or vestibular for each candidate.
Running the query:
SELECT * FROM questoes ORDER BY RAND() limit 5;
it returns 5 id of the questions.. Ex.: 8 26 24 30 4
I’m not getting (I don’t know, right) take these 5 ids and make the insert into the registration of this new candidate.
Be Welcome, describe in the question what problem you are having.
– André Lins
What is the error? What is happening?
– Marcelo de Andrade
Aline, it’s important that you describe what your difficulty is, not just what you want to do.
– André Lins
I can not do the INPUT of these 5 questions in the registration of this candidate.
– Aline Sousa Lima