query("SELECT *, DATE_FORMAT(joined_date, '%M %e, %Y') as formatted_joined_date FROM users WHERE role = 'player' ORDER BY points DESC, name ASC");
$players = $stmt->fetchAll();
foreach ($players as $key => &$player) {
$player['rank'] = $key + 1;
}
unset($player);
} catch (PDOException $e) {
die("DB ERROR: " . $e->getMessage());
}
// Prepare data for the view
$podium = array_slice($players, 0, 3);
$rest_of_players = array_slice($players, 3);
// Helper functions for the view. In a larger application, these might
// go into a separate 'helpers.php' file.
function get_trend_icon($trend) {
switch ($trend) {
case 'up':
return '';
case 'down':
return '';
default:
return '';
}
}
function get_trend_icon_modal($trend) {
switch ($trend) {
case 'up':
return '';
case 'down':
return '';
default:
return '';
}
}