我在这里有这个查询,这是我将它输出到 csv 的方式,有人可以帮助我吗?那里很乱,如果我将它打印为 Excel 会更好,并且我尝试了一些版本,但是我使用 odbc 查询的事实让我很难适应我在网上找到的示例.
$result = "SELECT forma.*, SMS_MONTIME.IDTICKET,SMS_MONTIME.MBYLLUR,
SMS_MONTIME.time_added FROM forma
LEFT JOIN SMS_MONTIME ON forma.ID = SMS_MONTIME.IDTICKET WHERE
forma.data_fillim >= '$df' AND forma.data_fillim <= '$dm' ORDER BY forma.id DESC";
$user_query = odbc_exec($connection, $result) or die(odbc_error());
//While loop to fetch the records
while($row = odbc_fetch_array($user_query))
{
$contents.=$row['klienti'].",";
$contents.=$row['id'].",";
$contents.=$row['tekniku_emer'].",";
$contents.=$row['telefoni'].",";
$contents.=$row['data_fillim'].",";
$contents.=$row['difekti'].",";
$contents.=$row['tekniku_mesazh'].",";
$contents.=$row['shenime'].",";
}
// remove html and php tags etc.
$contents = strip_tags($contents);
//header to make force download the file
header("Content-Disposition: attachment; filename=Kondicioner".date('d-m-Y').".csv");
print $contents;