[英]SQL Query Returning Only one row in result
我的查询结果只有一行。 我需要得到三个结果,但结果只显示一行。 我尝试过尽可能多地更改代码,但结果未显示多于一行。 我的代码如下。
elseif($module=="winners")
{
$result = mysqli_query($conn,"SELECT * FROM `contest` WHERE showresult=1");
if (mysqli_num_rows($result) > 0) {
$result = mysqli_query($conn,"select * FROM `contest_score` order by score desc, CAST(timequiz as DECIMAL(9,2)) ASC limit 0,3");
if (mysqli_num_rows($result) > 0) {
$response["scores"] = array();
while ($row = $result->fetch_assoc()) {
$scores = array();
$scores["id"] = $row["id"];
$scores["user_id"] = $row["user_id"];
$scores["username"] = $row["username"];
$scores["score"] = $row["score"];
$scores["played_date"] = $row["played_date"];
$scores["timequiz"] = $row["timequiz"];
$user_id = $row["user_id"];
$result = mysqli_query($conn,"SELECT user_image FROM `users` WHERE id=$user_id");
$temp_row = mysqli_fetch_assoc($result);
$scores["user_image"] = $temp_row["user_image"];
array_push($response["scores"], $scores);
}
$response["success"] = 1;
// echoing JSON response
echo json_encode($response);
请检查并让我知道是否有人可以帮助我解决我的问题。
谢谢
这可能与它有关:在循环中重新编写$result
变量。
$result = mysqli_query($conn,"SELECT user_image FROM 'users' WHERE id=$user_id");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.