我正在尝试从相关表中获取数据(测试1:M个用户),但输出为空。console为什么?
<?php
require "db.php";
header('Content-Type: application/json');
$get_result = ['auth' => false];
if (isset($_SESSION['logged_user'])) {
// get SESSION user id
$userid = $_SESSION['logged_user']->id;
// get user date
$user = R::Load('users', $userid);
foreach ($user->ownTestList as $test) {
if ($test->name == $_POST['name']) {
$progress = $test->progress;
$time = $test->time;
}
}
//we transfer the obtained data to js
$get_result = ['result' => $progress, 'time' => $time, 'auth' => true];
}
echo json_encode($get_result);
die();
?>
数据:
$ _ POST ['name'] ='对象'
$ _ SESSION ['logged_user'] = 1