-
Notifications
You must be signed in to change notification settings - Fork 0
/
playQuiz.php
84 lines (74 loc) · 3.55 KB
/
playQuiz.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="description" content="">
<meta name="author" content="">
<title>One Page Wonder - Start Bootstrap Template</title>
<?php include('headContent.php');?>
<script>
var result=parseInt(0);
function checkAns(x,y){
y = "Q" + y;
var ans = document.getElementById(y).value;
//alert(x);
if(x == ans){
result++;
alert(result);
}
}
</script>
</head>
<body>
<!-- Navigation -->
<?php include('navBar.php');
include('dbConnection.php')
?>
<br style="clear: both;">
<div class="container p-5" style="margin-top:32px;">
<form action='resultQuiz.php' method='post'>
<?php
if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST'){
$id = $_POST['userId'];
$playerName = $_POST['playerName'];
$query = "SELECT name FROM tbl_user where uId=". $id;
$row= mysqli_fetch_assoc(mysqli_query($con, $query));
$name = $row['name'];
echo "<center><h1>How Much You Know About ".$name."'s Cricket Hobby?<h1></center><br/>";
$query = "SELECT queNo FROM tbl_userque where userId=".$id;
$result = mysqli_query($con, $query);
$qno=1;
while($row = mysqli_fetch_assoc($result)){
$query2 = "SELECT que, optA, optB, optC, optD FROM tbl_que where qNo=". $row['queNo'];
$row2= mysqli_fetch_assoc(mysqli_query($con, $query2));
?>
<div>
<h4><?php echo "Q ".$qno.". ". str_replace("you", $name, $row2['que'])."<br/>"; ?>
</h4>
<h6>
<input type="hidden" name="Q<?php echo $qno;?>" value="<?php echo $row['queNo'];?>"/>
 <input type="radio" name="<?php echo "A".$qno;?>" value="optA" required/> <?php echo $row2['optA'];?><br/>
 <input type="radio" name="<?php echo "A".$qno;?>" value="optB" required/> <?php echo $row2['optB'];?><br/>
 <input type="radio" name="<?php echo "A".$qno;?>" value="optC" required/> <?php echo $row2['optC'];?><br/>
 <input type="radio" name="<?php echo "A".$qno;?>" value="optD" required/> <?php echo $row2['optD'];?>
</h6>
</div>
<br/>
<?php
$qno++;
}
?>
<input type="hidden" name="userName" value="<?php echo $name;?>"/>
<input type="hidden" name="userId" value="<?php echo $id;?>"/>
<input type="hidden" name="playerName" value="<?php echo $playerName;?>"/>
<center><input class='btn btn-success' type='submit' value='Show Result'/></center>
</form>
<?php
}else{
header('Location: index.php');
}
?>
</div>
<!-- Footer -->
<?php include('footer.php');?>
</body>
</html>