<?php
##############################################################################
# add_games.php3                                                             #
# ajout de matchs au Kestufoot                                               #
#                                                                            #
# Copyright ViralGames SARL 2000                                             #
##############################################################################

include("../config.php3");
include($BIB."bib_generic.php3");

//echo $SERVER_URL;
# pas de timeout possible qql soit l'action effectuée
set_time_limit($TIME_LIMIT);

# le script continue une fois qu'il est lancé quel que soit l'état de la connection après
ignore_user_abort(true); 

# si aucune date n'a été entrée,on affiche la date actuelle dans les champs texte
$current_european_date = date("Y-m-d H:i:s", my_local_time());
if (!isset($ShowTime))
	$ShowTime = $current_european_date;
if (!isset($Date))
	$Date = $current_european_date;

// on affiche les catégories disponibles dans un tableau
?>
<html>
<head></head>
<link rel="stylesheet" href="admin.css">
<body rightmargin=0>
<div align=center class=trTitle>Ajouter des matchs</div>
<br>
<table border=1>
	<tr>
		<td>Joueur<td>echec<td>correct<td>perfect
	</tr>
<?php
/*
$rowsPlayer = main_db_query("SELECT * FROM Players");
while($rowPlayer = db_fetch_array($rowsPlayer))
{
	$rowsPari = main_db_query("SELECT COUNT(*) AS total, Result, SUM(Result) AS laSum FROM Paris WHERE Result > 0 AND PlayerId='".$rowPlayer['Id']."' GROUP BY Result ORDER BY Result ASC");
	$rowEchec = db_fetch_assoc($rowsPari);
	$rowCorrect = db_fetch_assoc($rowsPari);
	$rowPerfect = db_fetch_assoc($rowsPari);

	$nbParis = ($rowEchec['total'] + $rowCorrect['total'] + $rowPerfect['total']);
	$totalLaSum = ($rowEchec['laSum'] + $rowCorrect['laSum'] + $rowPerfect['laSum']);
	$lvl = number_format( $totalLaSum / $nbParis, 2, ',', ' ');
	$CoPer = $rowCorrect['total'] + $rowPerfect['total'];
	echo "<tr><td>".$rowPlayer['Id']." NickName:".$rowPlayer['NickName']."</td><td>".$lvl."</td><td>".$totalLaSum."<td>".$nbParis."</td><td>".$CoPer."</td></tr>";
}
*/
/*
$rows = main_db_query("SELECT COUNT(*) AS total, SUM(Result) AS laSum, PlayerId FROM Paris GROUP BY PlayerId ORDER BY total DESC");
while($row = db_fetch_array($rows))
{
	$player = getplayer2($row['PlayerId']);
	$lvl = number_format($row['laSum'] / $row['total'], 2, ',', ' ');
	echo "<tr><td>".$row['PlayerId']." NickName:".$player['NickName']."</td><td>".$lvl."</td><td>".$row['laSum']."<td>".$row['total']."</td></tr>";
}


*/

$rows = main_db_query("SELECT COUNT(*) AS total, Result, PlayerId FROM Paris WHERE Result > 0 GROUP BY PlayerId, Result ORDER BY PlayerId asc, Result asc");
$colonne = 0;
$r = 0;
$tmp=0;
$lastPlayerId = "";

while($row = db_fetch_array($rows))
{
	if ($row['PlayerId'] != $lastPlayerId)
	{
		echo "<tr><td>".$row['PlayerId'];
		$colonne = 0;
		$lastPlayerId = $row['PlayerId'];
		$tmp=0;
	}
	
	$colonne++;
	/*
	if ($row['Result'] != $colonne)
	{
		continue;
	}
	*/
	echo "<td>".$row['total'];
	if ($row['Result'] > 1)
		$tmp += $row['total'];
	$r++;
	flush();
}

?>
</table>