33 lines
1.0 KiB
PHP
Executable File
33 lines
1.0 KiB
PHP
Executable File
<?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);
|
|
|