Blame view

pages/schools.php 1.65 KB
722c6952   Geoffrey PREUD'HOMME   schools: Nicer ex...
1
  <h2>Liste écoles participantes</h2>
56320b01   Jean Wasilewski   Added creds
2
  <?php
722c6952   Geoffrey PREUD'HOMME   schools: Nicer ex...
3
4
5
  require_once ("creds.php");
  
  try {
8cea2eb9   Geoffrey PREUD'HOMME   Beautifier passe
6
  
722c6952   Geoffrey PREUD'HOMME   schools: Nicer ex...
7
8
9
10
11
      $link = @mysql_connect(__MYSQL_HOSTNAME__, __MYSQL_USERNAME__, __MYSQL_PASSWORD__);
  
      if (!$link) {
      	throw new Exception('Impossible de se connecter : ' . mysql_error());
      }
8cea2eb9   Geoffrey PREUD'HOMME   Beautifier passe
12
  
722c6952   Geoffrey PREUD'HOMME   schools: Nicer ex...
13
14
15
16
      if (!mysql_select_db('crep', $link)) {
          throw new Exception('Selection de la base de donnees impossible');
      }
      mysql_query("SET NAMES 'utf8'");
de397a8d   Geoffrey PREUD'HOMME   Removed contact f...
17
      $requete = "SELECT DISTINCT `nom`, `circonscription`, `adresse`, `enseignant` FROM `school` ORDER BY nom ASC";
722c6952   Geoffrey PREUD'HOMME   schools: Nicer ex...
18
19
20
  
      $resultat = mysql_query($requete);
  
c5246861   Geoffrey PREUD'HOMME   Obviously catched...
21
22
23
24
      if (!$resultat) {
      	throw new Exception('Résultat vide.');
      }
  
722c6952   Geoffrey PREUD'HOMME   schools: Nicer ex...
25
      mysql_close($link);
56320b01   Jean Wasilewski   Added creds
26
  ?>
368cb3c0   Jean Wasilewski   Added school list
27
28
29
30
31
  
  <center>
  	<table class="table table-striped table-responsive table-bordered">
  		<div class="panel_heading">
  			<thead>
8cea2eb9   Geoffrey PREUD'HOMME   Beautifier passe
32
  				<tr>
368cb3c0   Jean Wasilewski   Added school list
33
34
  					<th>Nom de l'école</th>
  					<th>Circonscription</th>
c8a4fc85   Geoffrey PREUD'HOMME   Also where did th...
35
  					<th>Adresse</th>
722c6952   Geoffrey PREUD'HOMME   schools: Nicer ex...
36
  					<th>Enseignant</th>
368cb3c0   Jean Wasilewski   Added school list
37
38
39
40
41
  				</tr>
  			</thead>
  		</div >
  		<tbody>
  <?php
8cea2eb9   Geoffrey PREUD'HOMME   Beautifier passe
42
  
722c6952   Geoffrey PREUD'HOMME   schools: Nicer ex...
43
44
45
46
47
48
49
50
51
52
53
      while ($row = mysql_fetch_assoc($resultat)) {
          echo '<tr>';
          echo '<td>';
          echo '<p>' . $row['nom'] . '</p>';
          echo '</td>';
          echo '<td>';
          echo '<p>' . $row['circonscription'] . '</p>';
          echo '</td>';
          echo '<td>';
          echo '<p>' . $row['adresse'] . '</p>';
          echo '</td>';
4bb3187b   Geoffrey PREUD'HOMME   Re-added teacher ...
54
55
56
          echo '<td>';
          echo '<p>'.$row['enseignant'].'</p>';
          echo '</td>';
722c6952   Geoffrey PREUD'HOMME   schools: Nicer ex...
57
58
          echo '</tr>';
      }
368cb3c0   Jean Wasilewski   Added school list
59
  ?>
722c6952   Geoffrey PREUD'HOMME   schools: Nicer ex...
60
  
368cb3c0   Jean Wasilewski   Added school list
61
62
63
  		</tbody>
  	</table>
  </center>
722c6952   Geoffrey PREUD'HOMME   schools: Nicer ex...
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  <?php
  }
  catch(Exception $e) {
  ?>
  <div class="alert alert-danger" role="alert">
  Impossible d'afficher la liste des écoles participantes.<br/>
  Merci de rééssayer ultérieurement.
  </div>
  <!--
  <?php
  echo $e;
  ?>
  -->
  <?php
  }
  ?>