csv.php 727 B

12345678910111213141516171819202122
  1. <?php
  2. $host = "kurek620.beget.tech";
  3. $username = "kurek620_baze";
  4. $password = "6910WASD579h";
  5. $database = "kurek620_baze";
  6. $mysql = new mysqli($host, $username, $password, $database);
  7. if($mysql->connect_error){
  8. die("Ошибка подключения". $mysql->connect_error);
  9. }
  10. $file = fopen('Statisic.csv', 'w');
  11. fwrite($file, "\xEF\xBB\xBF");
  12. fputcsv($file, array("Логин". ";". "Количестов". ";". "Сумма"));
  13. $result = mysqli_query($mysql, "SELECT * FROM `Orders`");
  14. While($Orders = mysqli_fetch_assoc($result))
  15. {
  16. fputcsv($file, array($Orders['login']. ";". $Orders['count_order']. ";". $Orders[' summ_order']));
  17. }
  18. fclose($file);
  19. header('Location: admin_page.php');
  20. ?>