Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "test.duemetri";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT * FROM votazione";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- $artista = $row["comico"];
- if (!isset($concorrente[$artista]))
- {
- $concorrente[$artista]= 1;
- }
- else
- {
- $concorrente[$artista]= $concorrente[$artista]+1;
- }
- }
- arsort($concorrente);
- echo "<table><tr><td>Concorrente</td><td>Punteggio</td></tr>";
- foreach ($concorrente as $key => $val)
- {
- echo "<tr><td>".$key . "</td><td>" . $val . "</td></tr>";
- }
- echo "</table>";
- } else {
- echo "0 results";
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement