Seems to be duplicate title, but i accessed all links and none of the pages helped me.
I have the following code:
//Check if form was submitted
if($_POST){
$number = $_POST['number'];
$selected_choice = $_POST['choice'];
$next=$number+1;
$total=4;
//Get total number of questions
$query="SELECT * FROM `questions` LIMIT 4";
$results = $mysqli->query($query) or die($mysqli->error.__LINE__);
$total=$results->num_rows;
//Get correct choice
$q = "select * from `choices` where question_number = $number and is_correct=1";
$result = $mysqli->query($q) or die($mysqli->error.__LINE__);
$row = $result->fetch_assoc();
$correct_choice=$row['id'];
//compare answer with result
if($correct_choice == $selected_choice){
$_SESSION['score']++;
}
if($number == $total){
header("Location: final.php");
exit();
} else {
header("Location: formular1.php?n=".$next."&score=".$_SESSION['score']);
}
}
What i need to do, is to get a random number when form is submitted, but that number must be unique and don't repeat until session ends.
I have tried:
$number = range(1, 99);
shuffle($number);
..but i dont know how to integrate that :( Thank you!