File: //opt/Newsmag/bestplayers.php
<?php
/*
Template Name: Bestplayer
*/
$suffix = "";
if (isset($_GET['suffix'])) {
$suffix = $_GET['suffix'];
}
$uri = $_SERVER['REQUEST_URI'];
$bannerLaterale = $wpdb->get_var( "SELECT immagine FROM wp_plugin_atalantini_banner where tipo = 'QUADRATO'" );
//$totalPosts = str_replace("/","",str_replace("/ultime-news-","",$uri));
$totalPosts = $_GET['num'];
$current_user = wp_get_current_user();
?>
<?php get_header(); ?>
<div class="td-main-content-wrap">
<div class="td-container">
<div class="td-container-border">
<div class="td-pb-row">
<div class="td-pb-span12 td-main-content">
<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" . $suffix . " where vote != 's.v.' and vote != '' and game = g and player_id in (select distinct(id) from wp_plugin_atalantini_player" . $suffix . " where ruolo != 'ALLENATORE') group by player_id order by avg(vote) desc limit 1) as player_id, max(vote) from wp_plugin_votazioni" . $suffix . " where vote != 's.v.' and vote != '' and player_id in (select id from wp_plugin_atalantini_player" . $suffix . ") group by game order by count((vote));";
$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" . $suffix . " where id = " . $pl[$x] . ";");
foreach ( $teams as $player ) {
$playername = $player->nominativo;
$playerfoto = $player->file_player;
}
?>
<div class="grid_4 omega">
<div class="post_day_content">
<center>
<h1><?= $playername ?> (<?= $totale ?>)</h1>
<img 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 -->
<?php get_footer(); ?>