prepare("SELECT * FROM taxes WHERE id = ?"); $stmt->execute([$id]); $tax = $stmt->fetch(PDO::FETCH_ASSOC); if ($tax) { echo json_encode($tax); } else { http_response_code(404); echo json_encode(['error' => 'Tax not found']); } } else { $stmt = $pdo->query("SELECT * FROM taxes ORDER BY name"); $taxes = $stmt->fetchAll(PDO::FETCH_ASSOC); echo json_encode($taxes); } } catch (PDOException $e) { http_response_code(500); echo json_encode(['error' => 'Database error: ' . $e->getMessage()]); }