1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
| <?php
// require('fpdf.php');
// $pdf=new FPDF();
// $pdf->Open();
// $pdf->AddPage();
$sexe = getVariable('sexe');
$bassin = getVariable('bassin');
if (strlen($sexe)) {
$whSexe = "AND nageur.sexe = $sexe";
}
if (strlen($bassin)) {
$whBassin = "AND A.bassin = '$bassin'm";
}
if ($sexe == 1) {
$genre = 'GARCON';
} elseif ($sexe == 2) {
$genre = 'FILLE';
}
$cnn = new connexionBDD();
# CATEGORIES
$sql = 'SELECT DISTINCT categorie FROM resultat ORDER BY categorie ASC;';
$res = mysql_query($sql);
while($row = mysql_fetch_row($res)) {
$categories[] = $row[0];
}
# NAGES
$sql = 'SELECT DISTINCT idNage FROM resultat ORDER BY idNage ASC;';
$res = mysql_query($sql);
while($row = mysql_fetch_row($res)) {
$nages[] = $row[0];
}
# SQL DETAIL
$sql = <<<SQL
SELECT
nageur.nom as nom, nageur.prenom as prenom,
A.id AS id, A.idNageur AS idNageur, A.categorie AS categorie, A.idCompetition AS idCompetition,
A.idNage AS idNage, A.temps AS temps, A.place AS place, A.bassin AS bassin,
competition.date AS dateCompet, competition.nom AS evenement,
piscine.nom AS lieu, piscine.ville AS ville,
nage.nage AS nage
FROM resultat AS A
INNER JOIN nageur ON A.idNageur = nageur.id
INNER JOIN competition ON A.idCompetition = competition.id
INNER JOIN piscine ON competition.idPiscine = piscine.id
INNER JOIN nage ON A.idNage = nage.id
WHERE
A.temps > 0
$whSexe
$whBassin
AND A.idNage = '%s'
AND A.place >= 0
AND competition.date >=1283335200
AND competition.date <=1293793200
AND categorie = '%s'
ORDER BY
idNage ASC,
temps ASC
LIMIT 0,1;
SQL;
# EXTRACTION DES DETAILS
foreach ($nages as $idNage) {
foreach ($categories as $idCategorie) {
$sql = printf($sql, $idNage, $idCategorie);
$res = mysql_query($sql);
while ($row = mysql_fetch_assoc($res)) {
$row['dateCompet'] = date('d/m/Y', $row['dateCompet']);
$row['nom'] = strtoupper($row['nom']);
$details[] = array_map('trim', $row);
}
}
}
$o_connexionBDD->fermerConnexion();
### RENDU WEB ###
### TEMPLATES ###
$tplCategs =
function($p) {
return "<td>$p</td>";
};
$tplDetails =
function(array $p) {
return <<<WEB
<tr>
<td>
<br>
<p style="width:100px;"></p>
<p style="width:100px;">Nom : </p>
<p style="width:200px;"><strong><a href="index.php?page=nageurs&id={$p['idNageur']}">{$p['nom']} {$p['prenom']}</a></strong></p>
<br>
<p style="width:100px;"></p>
<p style="width:100px;background-color:#a0a0a0">Date : </p>
<p style="width:200px;background-color:#a0a0a0">{$p['dateCompet']}</p>
<br>
<p style="width:100px;"></p>
<p style="width:100px;">Temps : </p>
<p style="width:200px;">00:00.0</p>
<br>
<p style="width:100px;"></p>
<p style="width:100px;background-color:#a0a0a0">Evenement : </p>
<p style="width:200px;background-color:#a0a0a0">{$p['evenement']}</p>
<br>
<p style="width:100px;"></p>
<p style="width:100px;">Piscine : </p>
<p style="width:200px;">{$p['lieu']}</p>
<br>
<p style="width:100px;"></p>
<p style="width:100px;background-color:#a0a0a0">Lieu : </p>
<p style="width:200px;background-color:#a0a0a0">{$p['ville']}</p>
<br>
</td>
</tr>
WEB;
};
$categs = join("\n", array_map($tplCategs, $categories));
$details = join("\n", array_walk_recursive($details, $tplDetails));
echo <<<WEB
<h2>Filtre : $genre</h2>
<table style="width:500px;margin-left:125px;" cellspacing="0">
<tr>$categs</tr>
$details
</table>
WEB;
?> |
Partager