-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathincomp_task.php
31 lines (28 loc) · 972 Bytes
/
incomp_task.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
<?php
require('connect.php');
try {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
extract($_POST);
$stmt = $conn->prepare("SELECT id,studentname FROM students WHERE status = :status AND assignee = :assignee");
$stmt->execute(['assignee' => $assignee,'status' => 'Pending']);
if ($stmt->rowCount() > 0) {
// Records found
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$response = $result;
http_response_code(200);
} else {
// No record exist
$response = ['message' => 'No incomplete tasks'];
http_response_code(401);
}
} else {
// Invalid request method
$response = ['message' => 'Invalid request method'];
http_response_code(405);
}
// Return the response as JSON
echo json_encode($response);
} catch (PDOException $e) {
echo $e->getMessage();
}
$conn = null;