<?php
include("../includes/db_connection.php");

header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="associates.csv"');

$output = fopen("php://output", "w");
fputcsv($output, ['ID','Name','Email','Phone','Status']);

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

while($row = $result->fetch_assoc()){
    fputcsv($output, [$row['id'],$row['name'],$row['email'],$row['phone'],$row['status']]);
}
fclose($output);
exit;
?>