diff --git a/.gitignore b/.gitignore index 2f6719b..3d7b7f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /ProjetProgWeb/.env +/scripts/*.csv diff --git a/ProjetProgWeb/api.php b/ProjetProgWeb/api.php index 3c140d3..b203e00 100644 --- a/ProjetProgWeb/api.php +++ b/ProjetProgWeb/api.php @@ -3,11 +3,6 @@ require_once("class/dump.php"); $author_name = $_GET['author']; - $these_array = dump::getTheseByAuthor($author_name); - -$json = json_encode($these_array, JSON_PRETTY_PRINT); - -echo '
'; -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 ''; - ?> +