Admin Panel Formulare, Events Formular Fremdschlüssel-Spalte hinzugefügt
This commit is contained in:
29
formulare/get_results_lib.php
Executable file
29
formulare/get_results_lib.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?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;
|
||||
}
|
||||
Reference in New Issue
Block a user