-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloadstaff_not_in_proj.php
48 lines (28 loc) · 1.09 KB
/
loadstaff_not_in_proj.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
<?php
$project_ID_toload = $_POST['ID'];
$servername = "localhost";
$username = "host";
$dbpassword = "Team017FTW!";
$database = "makeitall";
$conn = new mysqli($servername, $username, $dbpassword, $database);
// SQL query to fetch staff not currently in team from the database
$sql = "SELECT DISTINCT users.user_id, users.name, users.email \n"
. "FROM users \n"
. "LEFT JOIN project_staff ON users.user_id = project_staff.user_id \n"
. "WHERE NOT EXISTS (SELECT 1 FROM project_staff WHERE users.user_id = project_staff.user_id AND project_staff.project_id = '$project_ID_toload') AND users.role = 'General Staff'";
$result = $conn->query($sql);
$allstaff = array();
if ($result->num_rows > 0) {
while ($staff = $result->fetch_assoc()) {
$eachstaff = array(
$staff['user_id'],
$staff['name'],
$staff['email'],
);
// Add the each indiviudal $task to the $alltasks array
array_push($allstaff, $eachstaff);
}
}
echo json_encode($allstaff);
$conn->close();
?>