0
データをCSV形式でエクスポートしようとしていますが、1番目のレコードが9番目、9番目が9番目のレコードです。ここで間違ってしまっいただきましDBからテーブルには、以下の方法があるかわからないテーブル全体を.csvファイルとしてダウンロードしていないのは10レコードだけです(laravel 5.3)
public function ExportAll(){
$student = Students::all();
$temp = tmpfile();
$heading = array('Name', 'Group');
fputcsv($temp, $heading);
foreach($student as $row) {
fputcsv($temp, array($row['name'],$row['group']));
}
fseek($temp, 0);
echo fread($temp, 1024);
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=Student.csv');
fclose($temp);
die;
}
私はこの方法をテーブル全体のusigをダウンロードしたいだけ1行そのダウンロードが ルートがある解決にお役立てください
Route::get('/student/ExportAll', '[email protected]');
として
ここに私は輸出へのリンクがありますas
<a href="/student/ExportAll">Export</a>
それは私が私の質問を更新しているだけイスト**文字列への変換**配列として10を –
現在、ダウンロードがエラーを与えるのレビューをご利用ください –