-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnextLab.php
More file actions
49 lines (33 loc) · 1.08 KB
/
Copy pathnextLab.php
File metadata and controls
49 lines (33 loc) · 1.08 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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
session_start();
include("credentials.php");
date_default_timezone_set('Europe/London');
$dateAndTime = new DateTime('now');
$weekday = $dateAndTime->format('w');
$time = $dateAndTime->format("H:i:s");
$mCode = 'null';
//Query the next module code
try {
$dsn = 'mysql:dbname='.$db_database.';host='.$db_host;
$pdo = new PDO($dsn,$db_username,$db_password);
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$stmt = $pdo->prepare("SELECT * FROM Labs WHERE (Start_Time BETWEEN :time AND '23:59:59') AND Weekday = :weekday ORDER BY Start_Time;");
$stmt->bindParam(':time', $time);
$stmt->bindParam(':weekday', $weekday);
$stmt->execute();
$rows = $stmt->fetchAll();
foreach ($rows as $row) {
$mCode = $row['mCode'];
break;
}
if ($mCode == 'null'){
echo "no lab after";
exit(0);
}
echo $mCode;
} catch (Exception $exception){
echo "<script type='text/javascript'> alert('Error when next module code query!') </script>";
exit(0);
}