<?php
// Include your database connection logic
include '../db.php';

// Assuming $pdo is your PDO connection

// Replace 'your_table_name' with your actual table name
$query = "SELECT id, code, fname, lname, region, mtaa, tin, phone, time FROM agents ORDER BY id DESC";

$stmt = $pdo->prepare($query);
$stmt->execute();
$agents = $stmt->fetchAll(PDO::FETCH_ASSOC);

// Close the statement (PDO connection remains open if not explicitly closed)
$stmt = null;

// Return the data in JSON format
header('Content-Type: application/json');
echo json_encode($agents);
?>
