对不起标题,但我不知道如何更好地解释。我导出了一个csv文件两个表,但最终的布局不是我所期待的,我真的不知道如何表现,我知道的是:
$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);
}
这导出了一个很好的csv,所有的列都很好地分开但是它并排显示了所有内容,正如你所看到的那样,我有day1nh和day1eh等,而不是输出:
workerNumber workerName socialSecurity day1nh day1eh
我想要这个:
workerNumber workerName socialSecurity day1nh day2nh etc
day1eh day2eh etc