trying to export my table to CSV file but I seem to be lost on what am doing wrong, I have my loaddata.php that has table that shows fields I have my Connection.php that will have database connection but when I run result what am getting is it exporting CSV with columns, but data is is bring back loaddata.php page with HTML formatting and every result
I have tried moving the included "loaddata.php" than I get brought back blank excel page with columns
<?php include('connection.php');
if(isset($_POST["export"])){
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=loaddata.csv');
$output = fopen("php://output", "w");
fputcsv($output, array(
'row number',
'Position ID',
'Description',
'firstname',
'lastname',
'country ',
'PhoneNumber'));
include ("loaddata.php")
$sqlcsv = "SELECT * FROM employeeTable";
$resultcsv = mysqli_query($conn,$sqlcsv)
or die('Invalid query sqlcsv: ' . mysqli_error());
while ($row = mysqli_fetch_assoc($resultcsv))
{
fputcsv($output, $row);
}
fclose($output);
}
?>