<html>
<head>
	<title>Les Parieurs</title>
</head>
<link rel="stylesheet" href="admin.css">
<body>
Répartition :<br>
Nb de jokers -> Nb de joueurs
<br>
<?php
include("generic.inc");
$ACHAT_JOKERS = 500;

$a = main_db_query("SELECT PlayerId, SUM(NbJokerDepense) AS total FROM History WHERE NbJokerDepense<0 GROUP BY PlayerId");
while($d = db_fetch_array($a))
{
	$tab[$d['PlayerId']] = $d['total'];
}

sort($tab);
foreach($tab as $key => $val)
{	
	if ($oldval != $val)
	{
		echo " ".$n." joueurs<br>";
		echo ($val*-1 / $ACHAT_JOKERS)." jokers";
		$n = 1;
	}
	else
		$n++;
		
	$oldval = $val;
}
echo " ".$n." joueurs <br><br>";
echo "nb joueurs ayant achetés : ".db_num_rows($a)."<br>";

// CS
$a = db_fetch_array(main_db_query("SELECT COUNT(*) AS total FROM Paris WHERE CS=3"));
echo "<br><br>Nb de joueurs sur les 2 coups spéciaux  : ".$a['total'];
$cs = $a['total'];

$a = db_fetch_array(main_db_query("SELECT COUNT(*) AS total FROM Paris WHERE CS=1"));
echo "<br>Nb de joueurs sur le coup spécial mi-temps : ".($a['total']+$cs/2);

$a = db_fetch_array(main_db_query("SELECT COUNT(*) AS total FROM Paris WHERE CS=2"));
echo "<br>Nb de joueurs sur le coup spécial 2ème prono : ".($a['total']+$cs/2);

$a = db_fetch_array(main_db_query("SELECT COUNT(*) AS total FROM Tombola"));
echo "<br>Nb de joueurs sur la tombola : ".($a['total']);

$a = db_fetch_array(main_db_query("SELECT SUM(Jokers) AS total FROM Tombola"));
echo "<br>Nb de jokers sur la tombola : ".($a['total']);

$a = db_fetch_array(main_db_query("SELECT AVG(Jokers) AS total FROM Tombola"));
echo "<br>Nb de jokers moyen sur la tombola : ".($a['total']);
?>
