<?php
include('../connection.php');

$query = "SELECT * FROM users";
$result = $conn->query($query);

if ($result->num_rows > 0) {
    $ticketData = array();
    while ($row = $result->fetch_assoc()) {
        // Prepare each ticket's data
        $response[] = [
                'id' => $row['id'],
                'recharge_id' => $row['recharge_id'],
                'user_id' => $row['user_id'],
                'username' => $row['username'],
                'name' => $row['name'],
                'address' => $row['address'],
                'phone' => $row['phone']
        ];
    }

} else {
    // Step 5: Prepare the failure response
    $response = [
        'status' => 'error',
        'message' => 'No tickets found',
    ];
}
header('Content-Type: application/json');
echo json_encode($response);

// Step 7: Close the database connection
$conn->close();
?>
