<?php
// api/get_my_tasks.php - 撈取某人發布的任務
header("Content-Type: application/json; charset=UTF-8");
require_once 'db.php';

$creator_id = isset($_GET['creator_id']) ? intval($_GET['creator_id']) : 0;

try {
    $stmt = $pdo->prepare("SELECT * FROM tasks WHERE creator_id = ? ORDER BY id DESC");
    $stmt->execute([$creator_id]);
    $data = $stmt->fetchAll(PDO::FETCH_ASSOC);
    echo json_encode(["status" => "success", "data" => $data]);
} catch (Exception $e) {
    echo json_encode(["status" => "error", "message" => $e->getMessage()]);
}
?>