version étudiant
This commit is contained in:
92
afficheEtudiants.php
Normal file
92
afficheEtudiants.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* PARAMETRES DE CONNEXION A LA BASE DE DONNEES
|
||||
*/
|
||||
$ip = 'localhost';
|
||||
$user = 'phpapp';
|
||||
$pass = 'myphp';
|
||||
$database = 'universite';
|
||||
|
||||
// Définition de la source des données pour PDO
|
||||
$dsn = "mysql:host=$ip;dbname=$database;charset=utf8mb4";
|
||||
|
||||
// Création de l'objet $dbh, de type PDO, qui est la ressource d'accès à la base
|
||||
try {
|
||||
$dbh = new PDO($dsn, $user, $pass);
|
||||
} catch (PDOException $e) {
|
||||
die("Erreur de connexion : ".$e->getMessage());
|
||||
}
|
||||
|
||||
?>
|
||||
<form action="afficheEtudiants.php" method="GET">
|
||||
<legend>Quels étudiants afficher ?</legend>
|
||||
<select name="diplome" id="diplome">
|
||||
<option value="N">Etudiants actuels</option>
|
||||
<option value="O">Anciens élèves</option>
|
||||
</select>
|
||||
<input type="submit" value="Valider" />
|
||||
</form>
|
||||
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<td><b>Nom</b></td>
|
||||
<td><b>Prénom</b></td>
|
||||
<td><b>Email</b></td>
|
||||
</thead>
|
||||
|
||||
<?php
|
||||
|
||||
// Il est vérifié que le diplome a bien été fourni à la page.
|
||||
if($_GET['diplome'] != null) {
|
||||
// écriture en amont de la requête
|
||||
$query = 'SELECT eNom, ePrenom, eEmail FROM etudiant WHERE eDiplome = "'.$_GET['diplome'].'"';
|
||||
// Exécution de la requête
|
||||
$stmtEtudiants = $dbh->query($query);
|
||||
|
||||
// Les résultats sont parcourus
|
||||
while($rowEtudiant = $stmtEtudiants->fetch())
|
||||
{
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?=$rowEtudiant['eNom'] ?></td>
|
||||
<td><?=$rowEtudiant['ePrenom']?></td>
|
||||
<td><?=$rowEtudiant['eEmail'] ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<a href="index.php">Retour à l'accueil</a>
|
||||
<?php
|
||||
|
||||
}
|
||||
// Fermeture de la connexion
|
||||
$pdoStmt = null;
|
||||
$dbh = null;
|
||||
|
||||
|
||||
// Petite aide au développement
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "<br>";
|
||||
echo "<h3>SUIVI DES VARIABLES POUR DEVELOPPEMENT : </h3>";
|
||||
echo "<h4>GLOBALS : </h4>";
|
||||
echo '<pre>';
|
||||
print_r($GLOBALS);
|
Reference in New Issue
Block a user