2024-06-15 17:47:50 +02:00
< ? php
// Informations de connexion à la base de données
require_once 'common.php' ;
session_start ();
2024-06-16 01:04:54 +02:00
$db = initDatabase ();
// Initialisation des événements si la table est vide
$event = " SELECT * FROM evenement " ;
if ( mysqli_num_rows ( mysqli_query ( $db , $event )) == 0 ) {
2024-06-16 10:48:38 +02:00
mysqli_query ( $db , " INSERT INTO evenement VALUES(1, 'Ceremonie d ouverture des JO','Cérémonie', 'Tour Eiffel', '2024-07-26', 'debut des JO', 0) " );
mysqli_query ( $db , " INSERT INTO evenement VALUES(2, 'match d ouverture Football','Football', 'Stade des Princes', '2024-07-27', 'premier match de foot', 0) " );
mysqli_query ( $db , " INSERT INTO evenement VALUES(3, 'course d ouverture','Natation', 'Piscine Olympique', '2024-07-27', 'premiere course', 0) " );
2024-06-16 01:04:54 +02:00
$event = mysqli_query ( $db , " SELECT * FROM evenement " );
}
// Construction de la requête dynamique
$query = " SELECT * FROM evenement WHERE 1=1 " ;
$params = [];
$types = " " ;
if ( ! empty ( $_GET [ 'sport' ])) {
$query .= " AND Sport = ? " ;
$params [] = $_GET [ 'sport' ];
$types .= " s " ;
}
if ( ! empty ( $_GET [ 'date' ])) {
$query .= " AND Date = ? " ;
$params [] = $_GET [ 'date' ];
$types .= " s " ;
}
if ( ! empty ( $_GET [ 'lieu' ])) {
$query .= " AND Lieux = ? " ;
$params [] = $_GET [ 'lieu' ];
$types .= " s " ;
}
// Ajout de l'ordre de tri
$order_by = $_GET [ 'order_by' ] ? ? 'Sport' ;
$order_dir = $_GET [ 'order_dir' ] ? ? 'ASC' ;
$query .= " ORDER BY $order_by $order_dir " ;
// Préparation de la requête
$stmt = mysqli_prepare ( $db , $query );
if ( $params ) {
mysqli_stmt_bind_param ( $stmt , $types , ... $params );
}
mysqli_stmt_execute ( $stmt );
$event = mysqli_stmt_get_result ( $stmt );
2024-06-15 17:47:50 +02:00
?>
2024-06-16 01:04:54 +02:00
<! DOCTYPE html >
< html lang = " fr " >
2024-06-15 17:47:50 +02:00
< head >
< meta charset = " utf-8 " >
2024-06-16 01:04:54 +02:00
< link rel = " icon " href = " ../img/jo2024.jpg " >
2024-06-15 17:47:50 +02:00
< link rel = " stylesheet " href = " ../css/style.css " >
< title > Évènements - Jeux Olympiques </ title >
</ head >
2024-06-16 01:04:54 +02:00
< body >
2024-06-15 17:47:50 +02:00
< header >
2024-06-16 01:04:54 +02:00
< h1 class = 'Hello' > Liste des Évènements </ h1 >
< nav >
2024-06-16 02:03:06 +02:00
< ? php
if ( isset ( $_SESSION [ 'login' ])) {
echo " <a href='../' class='categorie'>Page d'accueil</a> " ;
echo " <a href='profil.php'><img class='profil' src='https://dwarves.iut-fbleau.fr/~ghouar-t/SaeDEV2.2/img/photo-profil.png' alt='profil'></a> " ;
echo " <a href='deconnexion.php' class='categorie'>Déconnexion</a> " ;
}
else {
echo " <a href='../' class='categorie'>Page d'accueil</a> " ;
echo " <a href='connexion.php' class='categorie'>Connexion</a> " ;
echo " <a href='inscription.php' class='categorie'>Inscription</a> " ;
}
?>
2024-06-16 01:04:54 +02:00
</ nav >
</ header >
2024-06-16 17:25:25 +02:00
2024-06-16 15:02:27 +02:00
2024-06-15 17:47:50 +02:00
< div class = " ListeEvenement " >
< div >
2024-06-16 01:04:54 +02:00
< h2 > Liste des Évenements :</ h2 >
< form action = " " method = " GET " >
2024-06-15 17:47:50 +02:00
< div >
2024-06-16 01:04:54 +02:00
< input name = " sport " type = " text " id = " sport " placeholder = " Chercher un sport ... " value = " <?php echo htmlspecialchars( $_GET['sport'] ?? '', ENT_QUOTES); ?> " >
< input name = " lieu " type = " text " id = " lieu " placeholder = " Cherche par un lieu ... " value = " <?php echo htmlspecialchars( $_GET['lieu'] ?? '', ENT_QUOTES); ?> " >
< input name = " date " type = " date " id = " date " placeholder = " Cherche par une date ... " value = " <?php echo htmlspecialchars( $_GET['date'] ?? '', ENT_QUOTES); ?> " >
< button type = " submit " > Chercher </ button >
2024-06-15 17:47:50 +02:00
</ div >
</ form >
</ div >
2024-06-16 10:48:38 +02:00
< table class = " Event " >
2024-06-15 17:47:50 +02:00
< thead >
2024-06-16 01:04:54 +02:00
< tr >
2024-06-16 10:48:38 +02:00
< br >< th scope = " col " >< a href = " ?order_by=Nom&order_dir=<?php echo $order_by == 'Nom' && $order_dir == 'ASC' ? 'DESC' : 'ASC'; ?> " > Nom </ a ></ th >
< th scope = " col " >< a href = " ?order_by=Sport&order_dir=<?php echo $order_by == 'Sport' && $order_dir == 'ASC' ? 'DESC' : 'ASC'; ?> " > Sport </ a ></ th >
< th scope = " col " >< a href = " ?order_by=Lieux&order_dir=<?php echo $order_by == 'Lieux' && $order_dir == 'ASC' ? 'DESC' : 'ASC'; ?> " > Lieux de l ' évènement </ a ></ th >
< th scope = " col " >< a href = " ?order_by=Date&order_dir=<?php echo $order_by == 'Date' && $order_dir == 'ASC' ? 'DESC' : 'ASC'; ?> " > Date </ a ></ th >
< th scope = " col " >< a href = " ?order_by=NbInscrit&order_dir=<?php echo $order_by == 'NbInscrit' && $order_dir == 'ASC' ? 'DESC' : 'ASC'; ?> " > Nombre de Participant </ a ></ th >
2024-06-16 01:04:54 +02:00
</ tr >
2024-06-15 17:47:50 +02:00
</ thead >
< tbody >
2024-06-16 01:04:54 +02:00
< ? php
while ( $row = mysqli_fetch_assoc ( $event )) {
2024-06-16 15:02:27 +02:00
echo " <tr> <td scope='row'><a href='event.php?id= " . $row [ 'id' ] . " '><br> " . $row [ 'Nom' ] . " </td><td><br> " . $row [ 'Sport' ] . " </td><td><br> " . $row [ 'Lieux' ] . " </td><td><br> " . $row [ 'Date' ] . " </td><td><br> " . $row [ 'NbInscrit' ] . " </td></tr> " ;
2024-06-16 01:04:54 +02:00
}
?>
</ tbody >
2024-06-15 17:47:50 +02:00
</ table >
2024-06-16 17:25:25 +02:00
< ? php
if ( isset ( $_SESSION [ 'role' ])) {
if ( $_SESSION [ 'role' ] == 'organizer' ) {
2024-06-16 17:58:12 +02:00
echo " <br><a href='creer_event.php' class='categorie'>Créer un évènement</a> " ;
2024-06-16 17:25:25 +02:00
}
}
?>
2024-06-15 17:47:50 +02:00
</ div >
< footer >
< ? php require_once ( 'footer.php' ); ?>
2024-06-16 01:04:54 +02:00
</ footer >
2024-06-15 17:47:50 +02:00
</ body >
</ html >