-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdate.php
More file actions
38 lines (36 loc) · 1.17 KB
/
Update.php
File metadata and controls
38 lines (36 loc) · 1.17 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
<?php
include 'MySQLConnection.php';
header('Content-Type: application/json');
$jsonString = file_get_contents('php://input');
$newJsonString = json_decode($jsonString, true);
$syllabusId = $newJsonString["syllabusId"];
$title = $newJsonString["title"];
$description = $newJsonString["description"];
$objective = $newJsonString["objective"];
$searchQuery = "SELECT syllabusID FROM Syllabuses WHERE syllabusID = $syllabusId AND status = 1";
$result = $dbConn -> query($searchQuery);
$numberfRows = $result -> num_rows;
if($numberfRows != 0)
{
$updateQuery = "UPDATE Syllabuses SET title = '$title', description = '$description', objectives = '$objective' WHERE syllabusID = $syllabusId";
if($dbConn->query($updateQuery) === TRUE)
{
http_response_code(202);
$selectQuery = "select * from Syllabuses where syllabusID = $syllabusId AND status = 1";
$result = $dbConn -> query($selectQuery);
$row = $result -> fetch_assoc();
$syllabusItem = new stdClass();
$syllabusItem = $row;
$syllabusItem = json_encode($syllabusItem);
echo($syllabusItem);
}
else {
http_response_code(500);
}
}
else
{
http_response_code(404);
}
$dbConn -> close();
?>