count_user.php 905 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. $query = "SELECT COUNT(*) as count FROM `Users`";
  11. $result = $mysql->query($query);
  12. $row = $result->fetch_assoc();
  13. $count = $row['count'];
  14. if(!$result){
  15. echo "что-то не так";
  16. }
  17. $query1 = "SELECT COUNT(*) as count1 FROM `reviews`";
  18. $result1 = $mysql->query($query1);
  19. $row1 = $result1->fetch_assoc();
  20. $count1 = $row1['count1'];
  21. if(!$result1){
  22. echo "что-то не так";
  23. }
  24. $query2 = "SELECT AVG(rating) as Avg_b FROM `reviews`";
  25. $result2 = $mysql->query($query2);
  26. $row2 = $result2->fetch_assoc();
  27. $Avg_b = $row2['Avg_b'];
  28. if(!$result2){
  29. echo "что-то не так";
  30. }
  31. ?>