Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

joshblevins's avatar

Paging through a quiz

I have quiz that I pull from a bank of question that is related by the quiz ID. When the student answers the questions starting with the first one I need to pull the next question.

How would I build the query to pull the next question in line.

Set up is

quiz

quiz_questions related by quiz_id

student responses is related by question_id

0 likes
1 reply
bugsysha's avatar

What about?

$quizQuestions = QuizQuestion::paginate(1);

In blade

foreach ($quizQuestions as $question)
    <p>{{ $question->body }}</p>
endforeach

Then just have form under that which will post to specific route in which you will redirect back while incrementing the page query param.

Please or to participate in this conversation.