<?php
include '../db.php';

header('Content-Type: application/json');

if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
    echo json_encode(['error' => 'Invalid log ID']);
    exit;
}

$log_id = intval($_GET['id']);

$query = "SELECT * FROM kpra_logs WHERE id = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $log_id);
$stmt->execute();
$result = $stmt->get_result();

if ($log = $result->fetch_assoc()) {
    echo json_encode($log);
} else {
    echo json_encode(['error' => 'Log not found']);
}

$stmt->close();
?>
