prepare("SELECT * from entries WHERE verify = 1"); if(!$statement->execute()) { echo "database Error"; } $entries = $statement->fetchAll(PDO::FETCH_ASSOC); if($_GET['export'] != null) { if($statement->rowCount() > 0){ $delimiter = ";"; $filename = "ehemalige_" . date('Y-m-d') . ".csv"; //create a file pointer $f = fopen('php://memory', 'w'); //set column headers $fields = array("ID", "Name", "E-Mail", "Telefon", "Wohnort", "Abschlussjahrgang", "Geburtstag", "Email validiert", "Tätigkeit", "Eintragungsdatum"); fputcsv($f, $fields, $delimiter); //output each row of the data, format line as csv and write to file pointer foreach ($entries as $entry) { $lineData = array($entry['id'], $entry['name'], $entry['mail'], $entry['phone'], $entry['location'], $entry['year'], $entry['birthday'], $entry['verify'], $entry['vocation'], $entry['creation']); fputcsv($f, $lineData, $delimiter); } //move back to beginning of file fseek($f, 0); //set headers to download file rather than displayed header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="' . $filename . '";'); //output all remaining data on a file pointer fpassthru($f); } exit; } returnHeader(); ?>
Name | Tätigkeit | E-Mail Adresse & Telefon | Wohnort | Jahrgang | Alter | Eintragung |
---|---|---|---|---|---|---|