csv.php 925 B

123456789101112131415161718192021222324
  1. <?php
  2. $host = "provalgk.beget.tech";
  3. $username = "provalgk_user";
  4. $password = "Qwer123.";
  5. $database = "provalgk_user";
  6. $mysql = new mysqli($host, $username, $password, $database);
  7. // Проверка соединения
  8. if($mysql->connect_error){
  9. die("Ошибка подключения". $mysql->connect_error);
  10. }
  11. $file = fopen('Statisic.csv', 'w');
  12. fwrite($file, "\xEF\xBB\xBF");
  13. fputcsv($file, array("Логин". ";". "Комментарий". ";". "Оценка"));
  14. $result = mysqli_query($mysql, "SELECT * FROM `reviews`");
  15. While($rivews = mysqli_fetch_assoc($result))
  16. {
  17. $login = $rivews['id_user'];
  18. $result1 = mysqli_query($mysql,"SELECT login from Login where id_user=$login");
  19. $login_user = mysqli_fetch_assoc($result1);
  20. fputcsv($file, array($login_user['login']. ";". $rivews['review']. ";". $rivews['rating']));
  21. }
  22. fclose($file);
  23. header('Location: Adminpage.php');
  24. ?>