-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
168 lines (136 loc) · 5.12 KB
/
index.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?php
require_once 'includes/config.php';
// Get page number
if (!isset($_GET['page']) || empty($_GET['page']))
$page = 1;
else
$page = htmlspecialchars($_GET['page']);
// Get search parameters
if (!isset($_GET['search']) || empty($_GET['search'])) {
$search = "";
$sql = "SELECT Cid, Id, Title, Description, Instructor, Start_Time, End_Time, Location, Start_Date, End_Date, Credit, Term, Campus FROM Courses LIMIT " . ($page - 1) * 25 . "," . (($page - 1) * 25 + 25);
}
else {
$search = htmlspecialchars($_GET['search']);
$sql = "SELECT Cid, Id, Title, Description, Instructor, Start_Time, End_Time, Location, Start_Date, End_Date, Credit, Term, Campus FROM Courses WHERE Title LIKE '%{$search}%' OR Description LIKE '%{$search}%' OR Course LIKE '%{$search}%' OR Department LIKE '%{$search}%' OR Instructor LIKE '%{$search}%' OR Id LIKE '%{$search}%' LIMIT " . ($page - 1) * 25 . "," . (($page - 1) * 25 + 25);
}
$courses = [];
if($result = mysqli_query($link, $sql)) {
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_array($result)) {
$courses[] = [
'Cid' => $row['Cid'],
'Id' => $row['Id'],
'Title' => $row['Title'],
'Description' => $row['Description'],
'Instructor' => $row['Instructor'],
'Start_Time' => $row['Start_Time'],
'End_Time' => $row['End_Time'],
'Location' => $row['Location'],
'Start_Date' => $row['Start_Date'],
'End_Date' => $row['End_Date'],
'Credit' => $row['Credit'],
'Term' => $row['Term'],
'Campus' => $row['Campus']
];
}
mysqli_free_result($result);
}
}
else {
echo "ERROR: Could not execute $sql. ";
}
mysqli_close($link);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Course Evaluations</title>
<?php include("includes/header_includes.php"); ?>
</head>
<body>
<div class="page-header">
<h1>
<?php if($logged_in) : ?>
Hi, <b><?php echo $username; ?></b>.<br>
<?php endif; ?>
<span> Welcome </span> to Rate UAkron!
</h1>
</div>
<?php include("includes/nav_bar.php"); ?>
<form class="search form-group" action="<?php echo ($_SERVER["PHP_SELF"]); ?>" method="GET">
<input type="text" name="search" class="inline-block search-box form-control" placeholder="Enter a course to search for">
<input type="submit" class="inline-block btn btn-info" value="Submit">
</form>
<?php foreach ($courses as $course): ?>
<table class="table text-align:left table-hover table-bordered results">
<thead>
<tr>
<th> <?php echo $course["Title"]?> </th>
</tr>
<tr class="warning no-result">
<td><i class="fa fa-warning"></i> No result</td>
</tr>
</thead>
<tbody>
<tr><td><?= $course["Id"] . " - " . $course["Term"]?></td></tr>
<?php if(!empty($course["Instructor"]) && $course["Instructor"] != " "): ?>
<tr><td><?= $course["Instructor"]?></td></tr>
<?php endif; ?>
<?php if(!empty($course["Description"]) && $course["Description"] != " "): ?>
<?php if(intval($course["Credit"]) > 1): ?>
<tr>
<td><?= $course["Description"] . " " . intval($course["Credit"]) . " Credits." ?></td>
</tr>
<?php else: ?>
<tr>
<td><?= $course["Description"] . " " . intval($course["Credit"]) . " Credit." ?></td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php if($course["Location"] != "T.B.A." && $course["Start_Time"] != "T.B.A."): ?>
<tr><td><?= $course["Start_Time"] . " - " . $course["End_Time"] . " at " . $course["Location"]?></td></tr>
<?php elseif($course["Start_Time"] != "T.B.A."): ?>
<tr><td><?= $course["Start_Time"] . " - " . $course["End_Time"]?></td></tr>
<?php elseif($course["Location"] != "T.B.A."): ?>
<tr><td><?= $course["Location"]?></td></tr>
<?php endif; ?>
<tr>
<td>
<a href="evaluate_course.php?id=<?php echo $course['Cid'] ?>" class="btn btn-success">Evaluate</a>
<a href="view_course_evaluations.php?id=<?php echo $course['Cid'] ?>" class="btn btn-success">View Evaluations</a>
</td>
</tr>
</tbody>
</table>
<?php endforeach ?>
<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item">
<a class="page-link" href="?page=<?php echo ($page - 1 == 0) ? $page : $page - 1?>&search=<?php echo $search ?>" aria-label="Previous">
<span aria-hidden="true">«</span>
<span class="sr-only">Previous</span>
</a>
</li>
<li class="page-item">
<a class="page-link" href="?page=<?php echo $page?>&search=<?php echo $search ?>"><?php echo $page?></a>
</li>
<?php if(count($courses) >= 25) : ?>
<li class="page-item">
<a class="page-link" href="?page=<?php echo $page + 1?>&search=<?php echo $search ?>"><?php echo $page + 1?></a>
</li>
<li class="page-item">
<a class="page-link" href="?page=<?php echo $page + 2?>&search=<?php echo $search ?>"><?php echo $page + 2?></a>
</li>
<li class="page-item">
<a class="page-link" href="?page=<?php echo $page + 1?>&search=<?php echo $search ?>" aria-label="Next">
<span aria-hidden="true">»</span>
<span class="sr-only">Next</span>
</a>
</li>
<?php endif; ?>
</ul>
</nav>
<?php include("includes/footer.php"); ?>
</body>
</html>