-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscore.php
90 lines (88 loc) · 3.88 KB
/
score.php
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html>
<?php include "SQL_connection.php"; ?>
<head>
<!--Title and favicon-->
<title>Quiz | Goal City</title>
<link rel="icon" type="image/png" sizes="32x32" href="media/withoutString.png">
<!-- Required meta tags -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--CSS/Javascript/Jquery files-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="main.css">
<style>
.btn{ font-size: 20px;}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<!--Social Media Icons-->
<script src="https://kit.fontawesome.com/9832cc157c.js" crossorigin="anonymous"></script>
</head>
<body>
<?php include('navbar.php');?>
<?php
$ch= $_GET["choice"];
$correct=0;
$total_que=9;
if(isset($_SESSION["answer"])){
for($i=1;$i<=sizeof($_SESSION["answer"]);$i++)
{
$answer="";
if($ch == "first")
$query = "SELECT idquiz,CorrectAnswer FROM quiz1 WHERE idquiz=$i";
else if($ch =="second")
$query = "SELECT idquiz,CorrectAnswer FROM quiz2 WHERE idquiz=$i";
else
$query = "SELECT idquiz,CorrectAnswer FROM quiz3 WHERE idquiz=$i";
$result=mysqli_query($link,$query);
while($row=mysqli_fetch_array($result))
$answer=$row["CorrectAnswer"];
if (isset($_SESSION["answer"][$i])){
if($answer==$_SESSION["answer"][$i])
$correct++;
}
}
}
?>
<div class="container" style="min-height:400px; width:90%; margin-top:150px; margin-bottom:150px; background-color:rgb(238, 214, 214)">
<div class="row">
<div class="col-lg-12">
<?php
if($_GET["choice"]=="first")
$temp=1;
else if($_GET["choice"]=="second")
$temp=2;
else if($_GET["choice"]=="third")
$temp=3;
mysqli_query($link,"INSERT INTO `scores`(`Username`, `Score`, `no_of_quiz`) VALUES ('$_SESSION[user]','$correct / 9','$temp')");
?>
<h1 style="justify-content:center; text-align:center;margin-top:80px;">You are done!</h1><br>
<h1 style='justify-content:center; text-align:center;margin-top:30px;'>You've reached <?php echo $correct ?> / <?php echo "9 ." ?></h1>
<?php
if(($correct/9)*100>=50)
echo "<h1 style='justify-content:center; text-align:center;'>Great job!</h1><br>";
else
echo "<h1 style='justify-content:center; text-align:center;'>Maybe you should try again!</h1><br>";?>
</div>
</div>
<div class="row" style="margin-top:50px;">
<div class="col-md-12" style="min-height:50px; padding:15px;justify-content:center; text-align:center;">
<div class="col-lg-12" text-center>
<input type="button" class="btn btn-success" value="Try again" onclick="load_total();">
<input type="button" class="btn submit" value="Done" onclick="submit();">
</div>
</div>
</div>
</div>
<?php include('footer.php');?>
<script type="text/javascript">
function load_total(){
var choice = "<?php echo "$ch";?>";
window.location="quiz.php?choice="+choice;
}
function submit(){
window.location="profile.php";
}
</script>
</body>