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)); echo (json_encode($out));
} }
} else if (isset($_GET["salleNameSearch"])){ } else if (isset($_GET["research"])) {
$research = $_GET["research"];
$salleNameSearch = $_GET["salleNameSearch"];
$stmt = $conn->prepare("SELECT salleID, nom FROM salleAlias WHERE MATCH nom AGAINST (? IN BOOLEAN MODE)"); $stmt = $conn->prepare("SELECT salleID, nom FROM salleAlias WHERE MATCH nom AGAINST (? IN BOOLEAN MODE)");
$stmt->execute([$salleNameSearch]); $stmt->execute([$research]);
$res = $stmt->fetchAll(); $res = $stmt->fetchAll();
$out = array(); $out = array();
for($i=0;$i<count($res);$i++) 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)); echo (json_encode($out));

View File

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

View File

@ -12,9 +12,25 @@ function httpGetAsync(theUrl, callback)
function researchRoom() 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() function putWaitNetworkScreen()