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
| $reponse = mysql_query("SELECT id, nom, prenom, date_de_naissance, sexe, classe, sport, statut, convocation FROM eleves WHERE statut= 0 AND classe = '" . mysql_real_escape_string($classe) . "' AND sport = '" . mysql_real_escape_string($sport) . "'");
$rows = array();
$ligne = 0;
$hsc = function($p)
{
return htmlspecialchars($p, ENT_QUOTES, 'utf-8');
};
while ($row = mysql_fetch_array($reponse)) {
$rows[] = <<<html
<tr><center>
<td>{$hsc(++$ligne)}</td>
<td>{$hsc($row['nom'])}</td>
<td>{$hsc($row['prenom'])}</td>
<td>{$hsc($row['classe'])}</td>
<td><center><input type="checkbox" name="id[]" value="{$row['id']}"></td>
html;
?>
<?php
//fin de la boucle, le tableau contient toute la BDD
}
mysql_close(); //deconnection de mysql
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Affichage en colonne avec BD - solution 2</title>
</head>
<body>
<center>
<table id="gestion">
<thead>
<tr>
<tr>
<th>Date</th>
<td style='background-color:#a0ffdf'><input type="text" name="date" id="date" style='background-color:#a0ffdf'/></td>
<th>Lieu</th>
<td style='background-color:#a0ffdf'><input type="text" name="lieu" id="lieu" style='background-color:#a0ffdf' /></td></td>
</tr>
<th>N°</th>
<th>Nom</th>
<th>Prenom</th>
<th>Classe</th>
<th>Sélectionner</th>
</tr>
</thead>
<tbody>
<?php
echo implode('', $rows);
?>
</tbody>
</table>
</body>
<br><input method="get" name="submit" type="submit" value="Envoyer" />
</form>
</div>
</div>
</body>
</html> |
Partager