Updated SQL File to remove dummy data.
This commit is contained in:
21
toggle_highlight.php
Normal file
21
toggle_highlight.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
require 'db.php';
|
||||
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
$type = $data['type'];
|
||||
$id = intval($data['id']);
|
||||
$highlighted = isset($data['highlighted']) && $data['highlighted'] ? 1 : 0;
|
||||
|
||||
if ($type === 'task') {
|
||||
$stmt = $pdo->prepare("UPDATE tasks SET highlighted = ? WHERE id = ?");
|
||||
$stmt->execute([$highlighted, $id]);
|
||||
echo json_encode(['success' => true]);
|
||||
} elseif ($type === 'subtask') {
|
||||
$stmt = $pdo->prepare("UPDATE subtasks SET highlighted = ? WHERE id = ?");
|
||||
$stmt->execute([$highlighted, $id]);
|
||||
echo json_encode(['success' => true]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => 'Invalid type']);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user