-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview_exams.php
More file actions
57 lines (46 loc) · 1.49 KB
/
view_exams.php
File metadata and controls
57 lines (46 loc) · 1.49 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
<?php
include 'db_connection.php';
session_start();
if (!isset($_SESSION['user_id'])) {
header('location:main_page.php');
exit();
}
if (!isset($_GET['exam_id'])) {
header('location:user_exams.php');
exit();
}
$exam_id = $_GET['exam_id'];
$select_exam = $conn->prepare("SELECT * FROM exams WHERE id = ?");
$select_exam->execute([$exam_id]);
$exam = $select_exam->fetch(PDO::FETCH_ASSOC);
$select_questions = $conn->prepare("SELECT * FROM exam_details WHERE exam_id = ?");
$select_questions->execute([$exam_id]);
$questions = $select_questions->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?= $exam['title'] ?> - Exam</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header class="header">
<section class="flex">
<a href="home.php" class="logo">Exam Overflow</a>
</section>
</header>
<section class="form-container">
<h3><?= $exam['title'] ?> (Grade: <?= $exam['grade'] ?>)</h3>
<?php foreach ($questions as $question) { ?>
<div class="box">
<p>Q: <?= $question['question'] ?></p>
<p>A: <?= $question['answer'] ?></p>
</div>
<?php } ?>
</section>
</body>
</html>