gpt4 book ai didi

php - MySQL JSON 编码数据

转载 作者:太空宇宙 更新时间:2023-11-03 12:30:03 24 4
gpt4 key购买 nike

<分区>

所以,我有这个 PHP 文件,它以 JSON 格式回显数据:

这是 PHP:

// Recieved the user id:
$userId = $_POST['userId'];

// Create connection
$con = mysqli_connect("123.com", "123", "123", "123", "1234");


// Check connection
if (mysqli_connect_errno($con)) {
echo "Failed to connect to database " . mysqli_connect_error();
}

// Work with the database to grab user statistics..
$getQuizMode = "SELECT `QuizModeScore` FROM `userstats` WHERE UserId = $userId";
$getChallengeMode = "SELECT `ChallengeModeScore` FROM `userstats` WHERE UserId = $userId";

$quizModeData = mysqli_query($con, $getQuizMode);
$challengeModeData = mysqli_query($con, $getChallengeMode);

// Build the response
$arr = array('Quiz' => $quizModeData, 'Challenge' => $challengeModeData);

// echo the json back:
echo json_encode($arr);

现在这是我的客户端 javascript:

var variableToSend = "109607962907537440488";

$.post('manageUserStats.php', {userId: variableToSend}, function(data){
console.log("Got these user stats: ", data);
});

当我看到控制台时,我看到这是已记录的:

Got these user stats:  {"Quiz":{"current_field":null,"field_count":null,"lengths":null,"num_rows":null,"type":null},"Challenge":{"current_field":null,"field_count":null,"lengths":null,"num_rows":null,"type":null}}

但是,我想获取此处显示的数据:

Stuff

我做错了什么?为什么我不能只得到这两个数字?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com