diff --git a/data/README.md b/data/README.md index bd53728b9d94db3f045b6b46b8589bae2de1c6f8..09d45d1d88dc03a1c8bd1de66a0444308a5bbdec 100644 --- a/data/README.md +++ b/data/README.md @@ -12,8 +12,8 @@ Voir comme exemple [Olympedia](https://www.olympedia.org/) Quelques jeux de données : -- `https://data.education.gouv.fr/explore/dataset/paris-2024-results-medals-oly-eng/information/` contient seulement les podiums de chaque discipline. Il est très bien. -- `https://data.education.gouv.fr/explore/dataset/paris-2024-liste-athletes-engages-olypara/information/` contient tous les athlètes. Je ne vois pas l'utilité pour l'instant. +- `https://data.education.gouv.fr/explore/dataset/paris-2024-results-medals-oly-eng/` contient seulement les podiums de chaque discipline. Il est très bien. +- `https://data.education.gouv.fr/explore/dataset/paris-2024-liste-athletes-engages-olypara/` contient tous les athlètes. Je ne vois pas l'utilité pour l'instant. - `https://www.kaggle.com/datasets/piterfm/paris-2024-olympic-summer-games` me semble beaucoup trop complet. - `https://www.kaggle.com/datasets/heesoo37/120-years-of-olympic-history-athletes-and-results` pas utilisé - `https://github.com/KeithGalli/Olympics-Dataset` pas utilisé \ No newline at end of file diff --git a/include/js/charts.js b/include/js/charts.js index 4e1962624523aa50c39017d395ddee21698c41ab..1a0f5ace76ccd6a5e5ab61dd8d8d7f2b0a368c84 100644 --- a/include/js/charts.js +++ b/include/js/charts.js @@ -21,7 +21,7 @@ httpRequest.onreadystatechange = () => { // 2. Définition de ce qu'il faut fair httpRequest.open('POST', 'include/php/data.php', true) // 3. Ouverture et configuration de la requête httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') // Requête SQL -const query = "SELECT country, COUNT(*) AS medals FROM joparis2024 GROUP BY country ORDER BY medals DESC LIMIT 10" +const query = "SELECT country, COUNT(*) AS medals FROM medals GROUP BY country ORDER BY medals DESC LIMIT 10" httpRequest.send(`query=${encodeURIComponent(query)}`) // 4. Envoi de la requête @@ -41,14 +41,14 @@ function drawChart(result) { data.addRows(dataArray) let piechart_options = { - title: "Pie Chart : Nombre de places dans chaque académie", + title: "Pie Chart : Nombre de médailles par pays", height: 600 } let piechart = new google.visualization.PieChart(document.getElementById('piechart_div')) piechart.draw(data, piechart_options) let barchart_options = { - title: "Barchart : Nombre de places dans chaque académie", + title: "Barchart : Nombre de médailles par pays", height: 600, legend: 'none' } diff --git a/include/js/geochart.js b/include/js/geochart.js index 82721cdfa793ebd8508b2236a01699752987b2db..bf9223d5027980fa1b49fd4923b9f1020da056eb 100644 --- a/include/js/geochart.js +++ b/include/js/geochart.js @@ -14,7 +14,7 @@ httpRequest.onreadystatechange = () => { } httpRequest.open('POST', 'include/php/data.php', true) httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') -const query = 'SELECT country, count(*) AS medals FROM joparis2024 GROUP BY country' +const query = 'SELECT country, count(*) AS medals FROM medals GROUP BY country' httpRequest.send(`query=${encodeURIComponent(query)}`) // 4. Envoi de la requête /* Fonction pour filtrer les pays d'Europe */ diff --git a/index.php b/index.php index a30a12ddb0f904db4b06fc71d03e1f80914bd017..b9530b979368c5fc91fbd628af9a1d8b168d1b6e 100644 --- a/index.php +++ b/index.php @@ -32,7 +32,7 @@ include 'include/php/functions.php'; <ol> <?php $dbh = db_connection(); -$sth = $dbh->prepare('SELECT country, COUNT(*) AS medals FROM joparis2024 +$sth = $dbh->prepare('SELECT country, COUNT(*) AS medals FROM medals GROUP BY country ORDER BY medals DESC LIMIT 5'); @@ -46,18 +46,17 @@ foreach ($result as $row) { </section> <section> - <h2>Les athlètes avec le plus de médailles</h2> + <h2>Les compétitions avec le plus d'athlètes</h2> <ol> <?php -$sth = $dbh->prepare('SELECT name, COUNT(*) AS medals FROM joparis2024 - WHERE gender != "X" - GROUP BY name - ORDER BY medals DESC +$sth = $dbh->prepare('SELECT event, COUNT(*) AS athletes FROM athletes + GROUP BY event + ORDER BY athletes DESC LIMIT 5'); $sth->execute(); $result = $sth->fetchAll(); foreach ($result as $row) { -echo '<li>' . $row['name'] . ' (<em>' . $row['medals'] . ' médailles</em>)</li>'; +echo '<li>' . $row['event'] . ' (<em>' . $row['athletes'] . ' athlètes</em>)</li>'; } ?> </ol> diff --git a/search.php b/search.php index 26cc690f9c38edbef5c0d2ba1c1d4e1a6c259c45..836848420f3bff2ee9466b2129bbe1740ad2e944 100644 --- a/search.php +++ b/search.php @@ -19,14 +19,14 @@ include 'include/php/functions.php'; <form method="get" action="search.php"> <label> - Choisis une formation : + Choisis une compétition : <input list="sports" name="event" style="width: 400px"> </label> <datalist id="sports"> <?php -// On remplit l'élément datalist (les suggestions pour le formulaire) avec les noms des formations +// On remplit l'élément datalist (les suggestions pour le formulaire) avec les noms des compétitions $dbh = db_connection(); -$sth = $dbh->prepare('SELECT event FROM joparis2024 +$sth = $dbh->prepare('SELECT event FROM medals GROUP BY event ORDER BY event ASC'); $sth->execute(); @@ -44,7 +44,7 @@ foreach ($result as $row) { // après avoir sélectionné une formation. Dans ce cas, on affiche les informations // de cette formation if (isset($_GET['event'])) { - $sth = $dbh->prepare('SELECT name, country, medal_code, event FROM joparis2024 + $sth = $dbh->prepare('SELECT name, country, medal_code, event FROM medals WHERE event = :event ORDER BY medal_code'); $donnees = [