num_rows !== 0) { while ($row = mysqli_fetch_object($result)) { $reference = "LD" . substr(strtoupper(umlaute_as_e($row->firstname)),0,1) . strtoupper(umlaute_as_e($row->lastname)); $price = getRegistrationPrice($row->birthday); $address = $row->street . ' ' . $row->house . ';' . $row->zip . ' ' . $row->city; $gender = $row->gender == 0 ? 'm' : ($row->gender == 1 ? 'w' : 'd'); $formattedRegistrationFrom = (new DateTime($row->registrationfrom))->format('d.m.Y'); $formattedBirthday = (new DateTime($row->birthday))->format('d.m.Y'); $export .= "{$row->lastname};{$row->firstname};{$row->iban};;{$row->bic};;{$row->bank};{$row->accountholder};{$reference};1;{$formattedRegistrationFrom};{$price}; ; ;\t{$row->phone};{$row->email};{$address};{$formattedBirthday};{$gender}\n"; } } mysqli_free_result($result); header('Content-Type: charset=utf-8'); header('Content-Disposition: attachment; filename="li-dance-export.csv";'); echo chr(239) . chr(187) . chr(191) . mb_convert_encoding($export, 'UTF-8', mb_list_encodings()); ?>