1

当我尝试导出除 NID 字段外的所有字段时都可以。这个数字长度是 17+ 所以,我怎样才能显示这个字段(nid)中的所有数字?我有

这是excel的例子

<?php

$filename = "hello.csv";
$query = "SELECT * FROM test_users";
$result_users = $this->conn->prepare($query);
$result_users->execute();
// Create array
$list = array ();

// Append results to array
array_push($list, array("## START OF May TABLE ##"));
while ($row = $result_users->fetch(PDO::FETCH_ASSOC)) {
    array_push($list, array_values($row));
}
array_push($list, array("## END OF May TABLE ##"));

// Output array into CSV file
$fp = fopen('php://output', 'w');
fputcsv($fp, ['Serial NO','English Name','Bangla Name','address','bn_address','user_no','nid','previous_cm','meter_no','type_of_user']);
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary");
foreach ($list as $ferow) {
    fputcsv($fp, $ferow);
}
4

0 回答 0