Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // output headers so that the file is downloaded rather than displayed
- $filename = "basket_" . date('Y-m-d') . ".csv";
- header('Content-Type: text/csv; charset=utf-8');
- header("Content-Disposition: attachment; filename="$filename"");
- // create a file pointer connected to the output stream
- $output = fopen('php://output', 'w');
- // output the column headings
- fputcsv($output, array(' ID модели ', ' Имя модели ', ' Фамилия модели ', ' День рождения ', ' Месяц рождения ', ' Год рождения ', ' Рост ', ' Мобильный телефон ', ' Контактное лицо ', ' Профиль модели(Фото и подробная инфо.) '));
- // fetch the data
- mysql_connect('localhost', '', '');
- mysql_select_db('');
- $rows = mysql_query("SELECT user.id, user.name, user.surname, user.day, user.month, user.year, user.height, user.phone_mob, user.contact, basket.user
- FROM user
- INNER JOIN basket
- ON user.id = basket.user
- ORDER BY basket.id;");
- // loop over the rows, outputting them
- while ($row = mysql_fetch_assoc($rows))
- {
- if (isset($row['user']))
- {
- $row['user'] = 'http://only-stars.ru/models?id='.$row['user'];
- }
- if ($row['name'] == '')
- {
- $row['name'] = "(не указано)";
- }
- if ($row['surname']== '')
- {
- $row['surname'] = "(не указано)";
- }
- if ($row['day'] == '')
- {
- $row['day'] = "(не указано)";
- }
- if ($row['month'] == '')
- {
- $row['month'] = "(не указано)";
- }
- if ($row['year'] == '')
- {
- $row['year'] = "(не указано)";
- }
- if ($row['height'] == '')
- {
- $row['height'] = "(не указано)";
- }
- if ($row['phone_mob'] == '')
- {
- $row['phone_mob'] = "(не указано)";
- }
- if ($row['contact'] == '')
- {
- $row['contact'] = "(не указано)";
- }
- fputcsv($output, $row);
- }
Add Comment
Please, Sign In to add comment