30 lines
994 B
PHP
Executable File
30 lines
994 B
PHP
Executable File
<?php
|
|
|
|
function get_type_by_name($name,$formularid){
|
|
global $db_id;
|
|
return mysqli_fetch_assoc(mysqli_execute_query($db_id,"SELECT `type` FROM `formulare-fields` WHERE `name`=? AND `formular`=?;",[$name,$formularid]))["type"];
|
|
}
|
|
function get_results($formularid){
|
|
global $db_id;
|
|
|
|
$data=[];
|
|
foreach(mysqli_execute_query($db_id,"SELECT `id`,`timestamp` FROM `formulare-ergebnisse` WHERE `formular`=?;",[$formularid]) 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"],$formularid);
|
|
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;
|
|
}
|
|
return $data;
|
|
}
|