52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../../connect.php';
|
|
|
|
$id = filterRequest("id");
|
|
|
|
// Array to hold the SET parts and parameters
|
|
$columnValues = [];
|
|
$params = [':id' => $id];
|
|
|
|
if (isset($_POST["driverID"])) {
|
|
$columnValues[] = "`driverID` = :driverID";
|
|
$params[':driverID'] = filterRequest("driverID");
|
|
}
|
|
|
|
if (isset($_POST["title"])) {
|
|
$columnValues[] = "`title` = :title";
|
|
$params[':title'] = filterRequest("title");
|
|
}
|
|
|
|
if (isset($_POST["body"])) {
|
|
$columnValues[] = "`body` = :body";
|
|
$params[':body'] = filterRequest("body");
|
|
}
|
|
|
|
if (isset($_POST["isShown"])) {
|
|
$columnValues[] = "`isShown` = :isShown";
|
|
$params[':isShown'] = filterRequest("isShown");
|
|
}
|
|
|
|
if (isset($_POST["dateCreated"])) {
|
|
$columnValues[] = "`dateCreated` = :dateCreated";
|
|
$params[':dateCreated'] = filterRequest("dateCreated");
|
|
}
|
|
|
|
// Check if there are fields to update
|
|
if (empty($columnValues)) {
|
|
jsonError("No fields to update");
|
|
exit;
|
|
}
|
|
|
|
$setClause = implode(", ", $columnValues);
|
|
$sql = "UPDATE `notificationCaptain` SET $setClause WHERE `id` = :id";
|
|
|
|
$stmt = $con->prepare($sql);
|
|
$stmt->execute($params);
|
|
|
|
if ($stmt->rowCount() > 0) {
|
|
jsonSuccess(null, "Notification data updated successfully");
|
|
} else {
|
|
jsonError("Failed to update notification data");
|
|
}
|
|
?>
|