Files
ritzenbergen-backend/bulitipp/tipps.php

37 lines
1.2 KiB
PHP
Executable File

<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json");
include("./check.php");
if(!isset($_GET["spieltag"])) die("GET spieltag fehlt");
$spieltag = $_GET["spieltag"];
if($spieltag==""||$spieltag=="null") die('{"error":"GET spieltag leer"}');
$data=[];
if(deadline($spieltag))
foreach(srowforeach("SELECT `user`, `tipp1`, `tipp2`, `tipp3`, `tipp4`, `tipp5`, `tipp6`, `tipp7`, `tipp8`, `tipp9` from `buli-tipps` where `spieltag`=?;",[$spieltag]) as $key=>$tippquery){
$userid=$tippquery[0];
$tippids=[$tippquery[1],$tippquery[2],$tippquery[3],$tippquery[4],$tippquery[5],$tippquery[6],$tippquery[7],$tippquery[8],$tippquery[9]];
foreach($tippids as $tippid){
$tipp=srowforeach("SELECT `paarung`, `score1`, `score2` FROM `buli-tipp` WHERE `id` = ?",[$tippid]);
array_push($data, [
"user" => $userid,
"tipp" => [
"paarungsid" => $tipp[0][0],
"heim" => $tipp[0][1],
"gast" => $tipp[0][2]
]
]);
}
}
$result=["reload"=>$reload, "data"=>$data];
echo json_encode($result, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);