Guest User

Untitled

a guest
Nov 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. // output headers so that the file is downloaded rather than displayed
  2.  
  3. $filename = "basket_" . date('Y-m-d') . ".csv";
  4. header('Content-Type: text/csv; charset=utf-8');
  5. header("Content-Disposition: attachment; filename="$filename"");
  6.  
  7. // create a file pointer connected to the output stream
  8. $output = fopen('php://output', 'w');
  9.  
  10. // output the column headings
  11. fputcsv($output, array(' ID модели ', ' Имя модели ', ' Фамилия модели ', ' День рождения ', ' Месяц рождения ', ' Год рождения ', ' Рост ', ' Мобильный телефон ', ' Контактное лицо ', ' Профиль модели(Фото и подробная инфо.) '));
  12.  
  13. // fetch the data
  14. mysql_connect('localhost', '', '');
  15. mysql_select_db('');
  16. $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
  17. FROM user
  18. INNER JOIN basket
  19. ON user.id = basket.user
  20. ORDER BY basket.id;");
  21.  
  22. // loop over the rows, outputting them
  23. while ($row = mysql_fetch_assoc($rows))
  24. {
  25. if (isset($row['user']))
  26. {
  27. $row['user'] = 'http://only-stars.ru/models?id='.$row['user'];
  28. }
  29. if ($row['name'] == '')
  30. {
  31. $row['name'] = "(не указано)";
  32. }
  33. if ($row['surname']== '')
  34. {
  35. $row['surname'] = "(не указано)";
  36. }
  37. if ($row['day'] == '')
  38. {
  39. $row['day'] = "(не указано)";
  40. }
  41. if ($row['month'] == '')
  42. {
  43. $row['month'] = "(не указано)";
  44. }
  45. if ($row['year'] == '')
  46. {
  47. $row['year'] = "(не указано)";
  48. }
  49. if ($row['height'] == '')
  50. {
  51. $row['height'] = "(не указано)";
  52. }
  53. if ($row['phone_mob'] == '')
  54. {
  55. $row['phone_mob'] = "(не указано)";
  56. }
  57. if ($row['contact'] == '')
  58. {
  59. $row['contact'] = "(не указано)";
  60. }
  61. fputcsv($output, $row);
  62. }
Add Comment
Please, Sign In to add comment