Sorry for the title, but i didn´t know how to explain better. I´m exporting to a csv file two tables, but the final layout isn´t what i´m expecting, and i really don´t know how to perfom this, what i have right know is:
$sql = "SELECT a.number, a.location,a.confirmed etc etc FROM campain UNION ALL SELECT workerNumber, workerName, socialSecurity,day1nh,day1eh,day2nh,day2eh etc etc FROM timesheet";
$qry = $pdo->prepare($sql);
$qry->execute();
$filename = "exportcsv/file".time().".csv";
$data = fopen($filename, 'w');
$row = $qry->fetch(PDO::FETCH_ASSOC);
if ($row)
{
fputcsv($data,array_keys($row), $delimiter = ';');
while ($row)
{
$array = array_map("utf8_decode", array_values($row));
fputcsv($data,$array, $delimiter = ';');
$row = $qry->fetch(PDO::FETCH_ASSOC);
}
fclose($data);
}
This exports a nice csv with all the columns well separated but it shows me everything side-by-side, and as you can see i have day1nh and day1eh etc and instead of this on the output:
workerNumber workerName socialSecurity day1nh day1eh
i want this:
workerNumber workerName socialSecurity day1nh day2nh etc
day1eh day2eh etc