我有一个程序,用户可以在其中从数据库下载所有查询值的 csv 文件。但是,在我的一列中,我需要连接“序列号 -”和我的 m.sr_no 值。我怎么可能做到这一点?
if(isset($_POST["Export"])){
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=Sample.csv');
$output = fopen("php://output", "w");
fputcsv($output, array('SR_NO', 'MODEL', 'EWR_NO', 'BUILD_NAME', 'SA_MB', 'DESTINATION', 'REQUESTOR', 'PURPOSE', 'WAFERNUM',
'CELL', 'QTY', 'MATERIAL_FORM', 'SAMPLE_CRITERIA', 'REQUEST_DATE', 'SORTING_ECD', 'HGA_ECD', 'STATUS', 'UPDATED_BY', 'REMARKS'));
$query = "SELECT m.sr_no, a.model, m.ewr_no, m.build_name, m.sa_mb, a.destination, m.requestor, m.purpose, m.wafernum,
m.cell, m.qty, a.material_form, a.criteria, m.request_date, m.sorting_ecd, m.hga_ecd, m.status, m.updated_by, m.remarks, m.id_sorting, a.id_optionlist
FROM sorting m
INNER JOIN dynamic_optionlist a ON m.id_sorting = a.id_optionlist
WHERE STATUS in ('Open','On-Going','On-Queue','Done')";
$result = mysqli_query($conn, $query);
while($row = mysqli_fetch_assoc($result))
{
fputcsv($output, $row);
}
fclose($output);
}