forked from prakharsingh1312/cusiege
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre3.php
More file actions
71 lines (37 loc) · 1.12 KB
/
Copy pathpre3.php
File metadata and controls
71 lines (37 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
session_start();
require_once('Assets/php/dbconfig.php');
//Choose Table accordingly
$table=$_SESSION['table'];
//Create a query to fetch all the questions
$query = "select * from pre_lev3";
//Run the query
$query_result = $dbconfig->query($query);
//Count the number of returned items from the database
$num_questions_returned = $query_result->num_rows;
if ($num_questions_returned < 1){
exit();}
//Create an array to hold all the returned questions
$questionsArray = array();
//Add all the questions from the result to the questions array
while ($row = $query_result->fetch_assoc()){
$questionsArray[] = $row;
}
//Create an array of Correct answers
$questions = array();
$questionid = array();
$done = array();
$score = array();
$i=1;
foreach($questionsArray as $question){
$questions[$i] = $question['question'];
$questionid[$i]= $question['questionid'];
$done[$i]=$question['done'];
$score[$i]=$question['score'];
$i++;
}
$_SESSION['q']=$questions;$_SESSION['qid']=$questionid;
$_SESSION['score']=$score;
$_SESSION['done']=$done;
$_SESSION['numq']=$num_questions_returned;
?>