Games played
Latest Games
| Song Name | Difficulty | Hit Ratio | Length | Time |
|---|
0) { $result = mysqli_fetch_assoc($result_temp); $most_played = $result['title']; } else { $most_played = "No songs played today"; } // ====================================================== // DATA POINTS FOR MOST PLAYED GRAPH // DATA POINTS FOR AVERAGE PLAY TIME GRAPH // ====================================================== $most_played_array = array(); $average_play_time_array = array(); $query = "SELECT DATE(`start_time`) AS date, COUNT(*) AS data, AVG(`play_time`) AS average FROM `playdata` GROUP BY DATE(`start_time`) ORDER BY `start_time` DESC LIMIT 0,7"; $result_temp = mysqli_query($connection, $query); while($result = mysqli_fetch_assoc($result_temp)) { $most_played_array[] = "{y: '" . $result['date'] . "', gp: " . $result['data'] . "}"; $average_play_time_array[] = "{y: '" . $result['date'] . "', pt: " . format($result['average'])['tseconds'] . "}"; } $most_played_array = array_reverse($most_played_array); $average_play_time_array = array_reverse($average_play_time_array); // ====================================================== // DATA POINTS FOR SCORES GRAPH // ====================================================== $scores_array = array(); $scores_names_array = array(); $query = "SELECT `date`, `score`, `username` FROM highscore ORDER BY `date` DESC LIMIT 0,28"; $result_temp = mysqli_query($connection, $query); while($result = mysqli_fetch_assoc($result_temp)) { $scores_array[] = "{y: '" . $result['date'] . "', sc: " . $result['score'] . "}"; $scores_names_array[] = "'" . $result['username'] . "'"; } $scores_array = array_reverse($scores_array); $scores_names_array = array_reverse($scores_names_array); // ====================================================== // PERCENTAGE OF DIFFICULTY // ====================================================== $easy = 0; $medium = 0; $hard = 0; $other = 0; $query = "SELECT `difficulty`, COUNT(1) as num, COUNT(1) / (SELECT COUNT(1) FROM `playdata` ) * 100 as avg FROM `songinstance` AS si, `playdata` as pd WHERE si.id = pd.songinstance GROUP BY `difficulty`"; $result_temp = mysqli_query($connection, $query); while($result = mysqli_fetch_assoc($result_temp)) { if(strtolower($result['difficulty']) == "easy") { $easy = $easy + round($result['avg']); } else if(strtolower($result['difficulty']) == "medium") { $medium = $medium + round($result['avg']); } else if(strtolower($result['difficulty']) == "hard") { $hard = $hard + round($result['avg']); } else { $other = $other + $result['avg']; } } $other = round($other); // ====================================================== // LATEST GAMES // ====================================================== $table = ""; $query = "SELECT `title`, `difficulty`, songinstance.id as siid, song.id as sid, (`enemies_hit` / (`enemies_missed` + `enemies_hit`)) * 100 as ratio, `start_time`, `play_time` FROM `playdata`, `songinstance`, `song` WHERE playdata.songinstance = songinstance.id AND songinstance.song = song.id ORDER BY `start_time` DESC LIMIT 3"; $result_temp = mysqli_query($connection, $query); while($result = mysqli_fetch_assoc($result_temp)) { $ratio = round($result['ratio']); $label = "danger"; if($ratio >= 40) $label = "warning"; if($ratio >= 80) $label = "success"; $table .= "