forked from Alek008/Raumplan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
25 lines (24 loc) · 964 Bytes
/
search.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
<?php
$verbindung = mysqli_connect("localhost", "rauminfo", "virtuos", "rauminfo") or
die ("keine Verbindung möglich. Benutzername oder Passwort sind falsch");
$input =$_GET["suche"];
//$abfrage = "SELECT * FROM mitarbeiter LEFT JOIN (raeume) on (mitarbeiter.raum_id = raeume.raum_id) WHERE mitarbeiter.nachname LIKE BINARY '%$input%' ORDER BY mitarbeiter.nachname;";
$abfrage="SELECT * FROM `mitarbeiter` LEFT JOIN (raeume) on (mitarbeiter.raum_id = raeume.raum_id) WHERE mitarbeiter.nachname LIKE '%$input%' OR mitarbeiter.vorname LIKE '%$input%' ;";
$ergebnis = mysqli_query($verbindung, $abfrage);
$results = array();
$i = 0;
while($r = mysqli_fetch_assoc($ergebnis)) {
$row = array();
$keys = array_keys($r);
foreach ($keys as $key) {
if ($r[$key] != null) {
$value = htmlspecialchars(utf8_encode($r[$key]));
// echo ($value."<br>");
$row[$key] = $value;
}
}
$results[$i++] = $row;
}
print json_encode($results);
}
?>