I can't find what I need. I trying to create at quizzer that takes questions from the database. Currently, it takes all the questions in the database and what I need it to take it randomly 10 questions. I am just starting to learn how to code.
Here are my getting questions code with answers:
<?php
//Set question number
$number = (int) $_GET['n'];
/*
* Get total questions
*/
$query = "SELECT * FROM `klausimai`";
//Get result
$results = $mysqli->query($query) or die($mysqli->error.__LINE__);
$total = $results->num_rows;
/*
* Get Question
*/
$query = "SELECT * FROM `klausimai`
WHERE question_number = $number";
//Get result
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
$question = $result->fetch_assoc();
/*
* Get Choices
*/
$query = "SELECT * FROM `atsakymai`
WHERE question_number = $number";
//Get results
$choices = $mysqli->query($query) or die($mysqli->error.__LINE__);
?>