<?php
$dbtable='resultats_2016_6km';
$title='Résultat trail 6km - 2016';
function capitalize_words($string) {
$string = explode(' ', $string);
foreach($string as $key) {
$string[$key] = ucfirst($string[$key]);
}
return implode(' ', $string);
}
echo "<script type=\"text/javascript\">\n";
echo "function verif(){\n";
echo " var theTRs = document.getElementsByTagName(\"tr\");\n";
echo " for (i = 1; i<theTRs.length; i++){\n";
echo " if (theTRs.item(i).style.backgroundColor == 'yellow'){\n";
echo " theTRs.item(i).style.backgroundColor = '';\n";
echo " theTRs.item(i).style.border='0px solid';\n";
echo " };\n";
echo " }\n";
echo " with (document.select_name)\n";
echo " {\n";
echo " if (the_name.selectedIndex == 0)\n";
echo " {\n";
echo " alert(\"Sélectionnez un nom svp.\");\n";
echo " }\n";
echo " else\n";
echo " {\n";
echo " document.getElementById(the_name.options[the_name.selectedIndex].value).style.backgroundColor = 'yellow';\n";
echo " document.getElementById(the_name.options[the_name.selectedIndex].value).style.border='2px solid #ccc';\n";
echo " document.getElementById('class' + the_name.options[the_name.selectedIndex].value).focus();\n";
echo " }\n";
echo " }\n";
echo "}\n";
echo "</script>\n";
// emplacement des données de connexion
require "connection.conf.php";
// connexion au serveur de donné
$link = @mysqli_connect("elosiamod1.mysql.db", "elosiamod1", "69NfvQAmrJgy", "elosiamod1") or die('Connexion au serveur de données impossible. Merci de revenir plus tard...') ;
$query = "SELECT * FROM ".$dbtable." ORDER by nom";
$result = mysqli_query ($link, $query) or die ('La requête de lecture a échoué');
echo "<h1 class=\"componentheading\">$title</h1>\n";
echo "<form name=\"select_name\" action=\"\">\n";
echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
echo "<tr>\n";
echo "<td>\n";
echo "<a name=\"top\"></a>Sélectionner un nom à chercher : <select name=\"the_name\" onchange=\"return verif();\"><option value=0>Dans cette liste...</option>";
if ($result) {
while($val = mysqli_fetch_array($result)) {
echo "<option value=".$val['class'].">".$val['nom']." ".$val['prenom']."</option>";
}
}
echo "</select>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</form>\n";
echo "<br>\n";
echo "<table border=\"0\" cellspacing=\"0\" width=\"100%\" style=\"border: 1px solid #FFFFFF\";>";
echo "<tr bordercolor=\"#FFFFFF\" class=\"TableResult\" >";
echo "<th align=\"center\" bgcolor=\"#CCCCCC\" width=\"20%\"><font color=\"#FFFFFF\">Class.</font></th>";
echo "<th align=\"left\" bgcolor=\"#CCCCCC\" width=\"52%\"><font color=\"#FFFFFF\">Coureur</font></th>";
echo "<th align=\"center\" bgcolor=\"#CCCCCC\" width=\"10%\"><font color=\"#FFFFFF\">Tps</font></th>";
echo "<th align=\"center\" bgcolor=\"#CCCCCC\" width=\"9%\"><font color=\"#FFFFFF\">Cat</font></th>";
echo "<th align=\"center\" bgcolor=\"#CCCCCC\" width=\"9%\"><font color=\"#FFFFFF\">Class. Cat</font></th>";
echo "</tr>";
$query = "SELECT * FROM ".$dbtable." ORDER by class";
$result = mysqli_query ($link, $query)
or die ('La requête de lecture a échoué') ;
$bColor = true;
while (list($class, $nom, $prenom, $sexe, $doss, $cat, $temps, $classcat) = mysqli_fetch_row ($result)) {
if ($bColor) {
$BgColor = "#709dc7";
}
else
{
$BgColor = "#dee0eb";
}
if ($bColor) {
$bColor = False;
}
else
{
$bColor = True;
}
echo " <tr bordercolor=\"#FFFFFF\" bgColor=\"$BgColor\" id=\"$class\" class=\"TableResult\" > \n".
" <td><p><a href=\"#top\"><img src=\"images/articles/up.gif\" border=\"0\" width=\"12\" height=\"12\" alt=\"haut de page\"><a class=\"ClassTable\" id=\"class$class\" href=\"#top\"><b>$class</b></a></p></td>\n".
" <td align=\"left\"><b>$nom $prenom (#$doss)</b></td>\n".
" <td align=\"center\"><b>$temps</b></td>\n".
" <td align=\"center\"><b>$cat</b></td>\n".
" <td align=center><b>$classcat</b></td>\n".
" </tr>\n";
}
mysqli_free_result($result);
mysqli_close($link);
echo "</table>";
?>