-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlocationsdata.php
More file actions
46 lines (38 loc) · 1.29 KB
/
locationsdata.php
File metadata and controls
46 lines (38 loc) · 1.29 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
<?php
$username = 'ram8ny';
$password = 'Spring2021!!';
$dbname = 'ram8ny';
$host = "usersrv01.cs.virginia.edu";
$dsn = "mysql:host=$host;dbname=$dbname";
$db = new PDO($dsn, $username, $password);
if(isset($_GET["locations"])) {
$sql = "SELECT * FROM Location";
$statement = $db->prepare($sql);
$statement->execute();
echo json_encode($statement->fetchAll());
}
if(isset($_GET['employees'])) {
$lid = $_GET['lid'];
$sql = "CALL getEmployees(:lid)";
$statement = $db->prepare($sql);
$statement->bindParam(":lid", $lid);
$statement->execute();
echo json_encode($statement->fetchAll());
}
if(isset($_GET['cashier'])) {
$eid = $_GET['eid'];
$sql = "SELECT * FROM Cashier WHERE eid = :eid";
$statement = $db->prepare($sql);
$statement->bindParam(":eid", $eid);
$statement->execute();
echo json_encode($statement->fetchAll());
}
if(isset($_GET['driver'])) {
$eid = $_GET['eid'];
$sql = "SELECT * FROM Driver WHERE eid = :eid";
$statement = $db->prepare($sql);
$statement->bindParam(":eid", $eid);
$statement->execute();
echo json_encode($statement->fetchAll());
}
?>