Commit bef627932bf9fb48644807acdff505c2cdb26537
1 parent
d86f122c
#8 plus de BDD mais un joli tableau
Showing
1 changed file
with
18 additions
and
40 deletions
Show diff stats
pages/schools.php
1 | +<?php | ||
2 | + require_once("creds.php"); | ||
3 | +?> | ||
1 | <h2>Liste écoles participantes</h2> | 4 | <h2>Liste écoles participantes</h2> |
2 | <?php | 5 | <?php |
3 | -require_once ("creds.php"); | ||
4 | - | ||
5 | -try { | ||
6 | - | ||
7 | - $link = @mysql_connect(__MYSQL_HOSTNAME__, __MYSQL_USERNAME__, __MYSQL_PASSWORD__); | ||
8 | - | ||
9 | - if (!$link) { | ||
10 | - throw new Exception('Impossible de se connecter : ' . mysql_error()); | ||
11 | - } | ||
12 | - | ||
13 | - if (!mysql_select_db('crep', $link)) { | ||
14 | - throw new Exception('Selection de la base de donnees impossible'); | ||
15 | - } | ||
16 | - mysql_query("SET NAMES 'utf8'"); | ||
17 | - $requete = "SELECT DISTINCT `nom`, `circonscription`, `adresse`, `enseignant` FROM `school` ORDER BY nom ASC"; | ||
18 | - | ||
19 | - $resultat = mysql_query($requete); | ||
20 | - | ||
21 | - if (!$resultat) { | ||
22 | - throw new Exception('Résultat vide.'); | ||
23 | - } | ||
24 | - | ||
25 | - mysql_close($link); | 6 | +$ecoles = array( |
7 | + array("nom" => "Condorcet", "circonscription" => "Roubaix", "adresse" => "Allée Denieppe, Willems", "enseignant" => "Mme Vernier"), | ||
8 | + array("nom" => "Cousteau", "circonscription" => "Lambersart", "adresse" => "58 Rue de la Fraternité, Marquette", "enseignant" => "Mr Griffon"), | ||
9 | + array("nom" => "Curie Ferry", "circonscription" => "Lambersart", "adresse" => "41 Rue Chanzy, Saint André", "enseignant" => "Mme Faidherbe"), | ||
10 | + array("nom" => "Curie Ferry", "circonscription" => "Lambersart", "adresse" => "41 Rue Chanzy, Saint André", "enseignant" => "Mme Pollet"), | ||
11 | + array("nom" => "Jeanne de Flandre", "circonscription" => "Lambersart", "adresse" => "Jeanne de Flandre, Marquette", "enseignant" => "Mme Dejardin"), | ||
12 | + array("nom" => "Jules Ferry", "circonscription" => "Lambersart", "adresse" => "241 Rue des Ecoles, Wambrechies", "enseignant" => "Mme Loonis"), | ||
13 | + array("nom" => "Les Peupliers", "circonscription" => "Lambersart", "adresse" => "23 Avenue des Peupliers, Saint André", "enseignant" => "Mme Lescaillet"), | ||
14 | + array("nom" => "Les Peupliers", "circonscription" => "Lambersart", "adresse" => "23 Avenue des Peupliers, Saint André", "enseignant" => "Mme Nicolas"), | ||
15 | + array("nom" => "Louise de Bettignies", "circonscription" => "Lambersart", "adresse" => "102 Avenue de la Liberté, Lambersart", "enseignant" => "Mme Paris"), | ||
16 | + array("nom" => "Marie Curie", "circonscription" => "Roubaix", "adresse" => "Rue Lannelongue, Hem", "enseignant" => "Mr Guillain"), | ||
17 | + array("nom" => "Petit Prince", "circonscription" => "Roubaix", "adresse" => "29 Avenue du Général Leclerc, Lys lez Lannois", "enseignant" => "Mme Delcroix"), | ||
18 | + array("nom" => "Samain", "circonscription" => "Lambersart", "adresse" => "28 Place de la République, Lambersart", "enseignant" => "Mme Vidal") | ||
19 | +); | ||
26 | ?> | 20 | ?> |
27 | 21 | ||
28 | <center> | 22 | <center> |
@@ -40,7 +34,7 @@ try { | @@ -40,7 +34,7 @@ try { | ||
40 | <tbody> | 34 | <tbody> |
41 | <?php | 35 | <?php |
42 | 36 | ||
43 | - while ($row = mysql_fetch_assoc($resultat)) { | 37 | + foreach($ecoles as $row) { |
44 | echo '<tr>'; | 38 | echo '<tr>'; |
45 | echo '<td>'; | 39 | echo '<td>'; |
46 | echo '<p>' . $row['nom'] . '</p>'; | 40 | echo '<p>' . $row['nom'] . '</p>'; |
@@ -61,19 +55,3 @@ try { | @@ -61,19 +55,3 @@ try { | ||
61 | </tbody> | 55 | </tbody> |
62 | </table> | 56 | </table> |
63 | </center> | 57 | </center> |
64 | -<?php | ||
65 | -} | ||
66 | -catch(Exception $e) { | ||
67 | -?> | ||
68 | -<div class="alert alert-danger" role="alert"> | ||
69 | -Impossible d'afficher la liste des écoles participantes.<br/> | ||
70 | -Merci de rééssayer ultérieurement. | ||
71 | -</div> | ||
72 | -<!-- | ||
73 | -<?php | ||
74 | -echo $e; | ||
75 | -?> | ||
76 | ---> | ||
77 | -<?php | ||
78 | -} | ||
79 | -?> |