-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetBookByLanguage.php
55 lines (48 loc) · 949 Bytes
/
getBookByLanguage.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
header('Content-Type: application/json; charset=utf-8');
include 'connexion.php';
$word = $_POST['word'];
try{
// Si la donnée est bien reçue ?
if(isset($word))
{
// Requête SELECT si le qrCode existe existe
$searchByWord = $db->prepare("SELECT * FROM `books` WHERE `languages` LIKE :word ORDER BY `languages` ASC");
$searchByWord->bindValue(":word", $word);
$searchByWord->execute();
$existBook = $searchByWord->rowCount();
while($a = $searchByWord->fetch())
{
$result[] = $a;
}
// Si l'immeuble existe
if($existBook > 0)
{
$msg = "Livres existants";
$success = 1;
}
else
{
$msg = "Aucun livre n'existe pour le moment";
$success = 0;
}
}
else
{
$msg = "Nous n'arrivons pas à avoir vos mots";
$success = 0;
}
}
catch(\Throwable $th)
{
$msg = "Error : ".$th->getMessage();
}
echo json_encode([
"data"=>[
$msg,
$existBook,
$success,
$result,
]
]);
?>