I have the following code to export a query to csv with php but it does not work, you know how I can get export the query to csv with php
require '../conn.php';
$sql = '(SELECT *)
UNION ALL
(SELECT * FROM senders INTO OUTFILE 'prueba.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n');';
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$response->state = true;
echo json_encode($response);
} else {
$response->state = false;
echo json_encode($response);
}
$ response I have declared it in "conn.php"