I have tried many of things, but none of them helped me. I have the following code:
//Check to see if score is set_error_handler
if (!isset($_SESSION['score'])){
$_SESSION['score'] = 0;
}
if (!isset($_SESSION["number"]) || !count($_SESSION["number"])) {
$_SESSION["number"] = range(1, 4);
shuffle($_SESSION["number"]);
}
//Check if form was submitted
if($_POST){
$number = $_POST['number'];
$selected_choice = $_POST['choice'];
$next = array_pop($_SESSION["number"]);
$total=2;
//Get total number of questions
$query="SELECT * FROM `questions` LIMIT 2";
$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']);
}
}
This part
$total=2
is what i can't find an solution for it. When quiz nr "2" is showing, after i press submit, "final.php" page apear with results. What i need to do, is that i need to limit number of quizes by number of pages, not by id number.
That's mean when 10 pages was showed for example, then must apear "final.php" page, not when id of page apear.
I'm so confused about that. I have tried so many thing, but none of them working. I know is not so complicated, but for me is. Thank you for understanding me
EDIT: I have tried
SELECT * FROM `questions` LIMIT 2
but don't work
</div>