<?php
global $wpdb;
$uri = $_SERVER['REQUEST_URI'];
//$totalPosts = str_replace("/","",str_replace("/ultime-news-","",$uri));
$totalPosts = $_GET['num'];
?>
<div class="page-content">
<div class="row clearfix">
<div class="grid_12 alpha">
<div class="grid_9 omega posts">
<div class="post_day mbf clearfix">
<img src="/wp-content/themes/atalantini/images/adagurdam.jpg" width="100%">
<br>
<?php
$pl = array();
$tm = array();
$sql = " select game as g,(select player_id from wp_plugin_votazioni where vote != 's.v.' and vote != '' and game = g and player_id in (select distinct(id) from wp_plugin_atalantini_player) order by vote desc limit 1) as player_id, max(vote) from wp_plugin_votazioni where vote != 's.v.' and vote != '' and player_id in (select id from wp_plugin_atalantini_player) group by game;";
$teams = $wpdb->get_results($sql);
foreach ( $teams as $player ) {
if (!in_array($player->player_id, $pl)) {
$pl[] = $player->player_id;
}
$tm[] = $player->player_id;
}
for ($x = 0; $x < count($pl); $x++) {
$totale = 0;
for ($i = 0; $i < count($tm); $i++) {
if ($tm[$i] == $pl[$x]) {
$totale++;
}
}
$playername = "";
$playerfoto = "";
$teams = $wpdb->get_results("select nominativo, file_player from wp_plugin_atalantini_player where id = " . $pl[$x] . ";");
foreach ( $teams as $player ) {
$playername = $player->nominativo;
$playerfoto = $player->file_player;
}
?>
<div class="grid_3 omega">
<div class="post_day_content">
<center>
<h1><?= $playername ?> (<?= $totale ?>)</h1>
<img height="200" src="/wp-content/themes/atalantini/player/<?= $playerfoto ?>">
</center>
</div><!-- /post content -->
</div><!-- /grid6 omega -->
<?php
}
?>
</div><!-- /post day -->
</div><!-- /grid11 -->
</div><!-- /grid12 -->
</div><!-- /row -->
</div><!-- /end page content -->