Room research

This commit is contained in:
Adrien Vannson 2021-10-14 22:09:36 +02:00
parent 7d16a1117f
commit a06faec64b
3 changed files with 49 additions and 34 deletions

View File

@ -54,18 +54,17 @@ if(isset($_GET["salle"])) {
echo (json_encode($out));
}
} else if (isset($_GET["salleNameSearch"])){
$salleNameSearch = $_GET["salleNameSearch"];
} else if (isset($_GET["research"])) {
$research = $_GET["research"];
$stmt = $conn->prepare("SELECT salleID, nom FROM salleAlias WHERE MATCH nom AGAINST (? IN BOOLEAN MODE)");
$stmt->execute([$salleNameSearch]);
$stmt->execute([$research]);
$res = $stmt->fetchAll();
$out = array();
for($i=0;$i<count($res);$i++)
$out[$i] = array("salleID" => $res[$i]['salleID'], "nom" => $res[$i]["nom"]);
$out[$i] = array("id" => $res[$i]['salleID'], "name" => $res[$i]["nom"]);
echo (json_encode($out));

View File

@ -112,14 +112,14 @@
<hr/>
<!-- Research results -->
<table class="table">
<table id="research-results-table" class="table" style="display:none;">
<thead>
<tr>
<th scope="col">Nom</th>
<th scope="col">Occupants</th>
</tr>
</thead>
<tbody>
<tbody id="research-results">
<tr>
<th scope="row">Amphi B</th>
<td></td>

View File

@ -12,9 +12,25 @@ function httpGetAsync(theUrl, callback)
function researchRoom()
{
let text = document.getElementById('research').value;
var research = document.getElementById('research').value;
var xhr = new XMLHttpRequest();
xhr.open('GET', 'api/request.php?research='+encodeURI(research), true);
xhr.onload = function() {
var table = document.getElementById('research-results');
table.innerHTML = '';
document.getElementById('research-results-table').style.display = 'block';
res = JSON.parse(xhr.responseText);
for (var i=0; i<res.length; i++) {
table.innerHTML += '<tr><th scope="row">' + res[i].id + '</th><td>' + res[i].name + '</td></tr>';
}
};
xhr.send(null);
}
function putWaitNetworkScreen()