Advertisement
Guest User

classifica ok comicselfie

a guest
May 17th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "test.duemetri";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14.  
  15. $sql = "SELECT * FROM votazione";
  16. $result = $conn->query($sql);
  17.  
  18. if ($result->num_rows > 0) {
  19. while($row = $result->fetch_assoc()) {
  20. $artista = $row["comico"];
  21. if (!isset($concorrente[$artista]))
  22. {
  23. $concorrente[$artista]= 1;
  24. }
  25. else
  26. {
  27. $concorrente[$artista]= $concorrente[$artista]+1;
  28. }
  29. }
  30. arsort($concorrente);
  31. echo "<table><tr><td>Concorrente</td><td>Punteggio</td></tr>";
  32. foreach ($concorrente as $key => $val)
  33. {
  34. echo "<tr><td>".$key . "</td><td>" . $val . "</td></tr>";
  35. }
  36. echo "</table>";
  37.  
  38. } else {
  39. echo "0 results";
  40. }
  41. $conn->close();
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement