prepare($query); $stmt->bindParam(':id', $_SESSION['agen'], PDO::PARAM_INT); $stmt->bindValue(':search', "%$search%", PDO::PARAM_STR); $stmt->bindValue(':limit', $limit, PDO::PARAM_INT); $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); $stmt->execute(); $data = $stmt->fetchAll(PDO::FETCH_ASSOC); // Return JSON response echo json_encode(['vouchers' => $data]); } catch (Exception $e) { // Handle any errors and return a JSON error response echo json_encode(['error' => 'Something went wrong: ' . $e->getMessage()]); } ?>