Admin Panel Formulare, Events Formular Fremdschlüssel-Spalte hinzugefügt

This commit is contained in:
R40fendt
2026-01-05 18:15:35 +01:00
parent ae2d80b47e
commit 30d6466bfb
7 changed files with 80 additions and 41 deletions

View File

@@ -2,6 +2,7 @@
header("Access-Control-Allow-Origin: *");
include("../../mysqlverbinden.php");
include("./get_results_lib.php");
if(!isset($_GET["id"])) die("GET id fehlt");
$formularid=$_GET["id"];
@@ -10,27 +11,6 @@ if(!mysqli_execute_query($db_id,"SELECT `public` FROM `formulare` WHERE `id`=?;"
die('{"error":"not_public"}');
}
function get_type_by_name($name){
global $db_id;
return mysqli_fetch_assoc(mysqli_execute_query($db_id,"SELECT `type` FROM `formulare-fields` WHERE `name`=?;",[$name]))["type"];
}
$data=[];
foreach(mysqli_execute_query($db_id,"SELECT `id`,`timestamp` FROM `formulare-ergebnisse`") as $ergebnis){
foreach(mysqli_execute_query($db_id,"SELECT `id`,`name`,`value` FROM `formulare-ergebnis` WHERE `ergebnisid`=?;",[$ergebnis["id"]]) as $row){
$type=get_type_by_name($row["name"]);
if(str_ends_with($row["name"],'[]')){
$row["name"]=substr($row["name"], 0, -2);
$row["value"]=json_decode($row["value"]);
}
$ergebnis["data"][]=[
"id"=>$row["id"],
"name"=>$row["name"],
"value"=>$row["value"],
"type"=>$type
];
}
$data[]=$ergebnis;
}
echo json_encode($data,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
echo json_encode(get_results($formularid),JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);