Formulare hinzugefügt

This commit is contained in:
R40fendt
2025-12-24 00:27:19 +01:00
parent 9e18989b42
commit b6e9462d68
5 changed files with 99 additions and 1 deletions

32
formulare/get_results.php Executable file
View File

@@ -0,0 +1,32 @@
<?php
header("Access-Control-Allow-Origin: *");
include("../../mysqlverbinden.php");
if(!isset($_GET["id"])) die("GET id fehlt");
$formularid=$_GET["id"];
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);