survey/controller/admin_suche.php
2023-04-03 14:41:10 +02:00

61 lines
1.5 KiB
PHP

<?php
require_once ("../config.inc.php");
$function = $_POST['function'];
if ($function == 'titel')
{
if (isset($_POST["term"]))
{
$term = strtoupper(trim($_POST["term"]));
$query = "SELECT distinct titel FROM jumi_noten_daten WHERE upper(titel) LIKE '%" . $term . "%'";
$result = $db->query($query) or die("Cannot execute titel");
if (mysqli_num_rows($result) > 0)
{
while ($row = $result->fetch_array())
{
$output[] = array(
"label" => $row['titel'],
"value" => $row['titel']
);
}
#}else{
# $output[] = array("label" => "keine Treffer");
}
echo json_encode($output);
}
}
if ($function == 'verlag')
{
if (isset($_POST["term"]))
{
$term = strtoupper(trim($_POST["term"]));
$query = "SELECT distinct verlag FROM jumi_noten_daten WHERE upper(verlag) LIKE '%" . $term . "%'";
$result = $db->query($query) or die("Cannot execute verlag");
if (mysqli_num_rows($result) > 0)
{
while ($row = $result->fetch_array())
{
$output[] = array(
"label" => $row['verlag'],
"value" => $row['verlag']
);
}
#}else{
# $output[] = array("label" => "keine Treffer");
}
echo json_encode($output);
}
}
?>