From 0f425bb06a1517e782a1367b8d481f69aec57b58 Mon Sep 17 00:00:00 2001
From: Florian SYLVAIN ';
-var_dump($json);
-echo '
';
+$json = json_encode($these_array);
+print_r($json);
diff --git a/ProjetProgWeb/app.js b/ProjetProgWeb/app.js
new file mode 100644
index 0000000..659e99a
--- /dev/null
+++ b/ProjetProgWeb/app.js
@@ -0,0 +1,26 @@
+
+function requestToApi(author) {
+ fetch(`api.php?author=${author}`)
+ .then(response => response.json())
+ .then(data => displayResults(data))
+}
+
+function displayResults(results) {
+ results.forEach(function(elem) {
+
+ let result = document.createElement('div')
+ result.classList.add('result-element')
+
+ let i = 0
+
+ elem.forEach(function(e) {
+ let child = document.createElement(i === 0 ? 'h1' : 'p')
+ child.innerText = e
+ result.appendChild(child)
+ i += 1
+ })
+
+ document.getElementById('results').appendChild(result)
+
+ })
+}
\ No newline at end of file
diff --git a/ProjetProgWeb/class/dump.php b/ProjetProgWeb/class/dump.php
index c110700..45cd44c 100644
--- a/ProjetProgWeb/class/dump.php
+++ b/ProjetProgWeb/class/dump.php
@@ -1,5 +1,7 @@
getPDO();
- $stmt = $pdo->query("SELECT * FROM theses WHERE author = '$author';");
+ $stmt = $pdo->query("SELECT * FROM theses WHERE author LIKE '%$author%';");
$i = 0;
while ($obj = $stmt->fetchObject()) {
$theses_array[$i] = array();
diff --git a/ProjetProgWeb/index.php b/ProjetProgWeb/index.php
index 3a562b6..2d6894e 100644
--- a/ProjetProgWeb/index.php
+++ b/ProjetProgWeb/index.php
@@ -5,29 +5,21 @@
+
'; - var_dump($json); - echo ''; - ?> +