gpt4 book ai didi

Php Mysql 只回显一半结果,有时甚至没有

转载 作者:行者123 更新时间:2023-11-29 11:00:29 25 4
gpt4 key购买 nike

我正在尝试回显用户名。我有一个表,其中只有 USERID ,然后我获取该 USEDID 并将其与另一个表进行比较,并从那里回显 USERNAME 。但是如果有 50 个条目,那么它只会回显 25 。

这是代码

<?php while($row = mysqli_fetch_assoc($result)) {
$user_id = $row['user_id'];
$result2 = mysqli_query($conn, "select * from `users` WHERE `user_id` = '$user_id'");
$row2 = mysqli_fetch_assoc($result2);
while($row2 = mysqli_fetch_assoc($result2)){
$username = $row2['username'];
}
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['user_id']; ?></td>
<td><?php echo $username; ?></td>
<td><?php echo $row['points']; ?></td>
</tr>

This above code doesnt echo anything at all in username but echo all results

如果我改变

$row2 = mysqli_fetch_assoc($result2);

$row2 = mysqli_fetch_assoc($result);

It echo everything with username but only few/half results

与此相关的其他代码

$result = mysqli_query($conn, "select * from `lottery`");
$row = mysqli_fetch_assoc($result);

最佳答案

删除此行:

$row2 = mysqli_fetch_assoc($result2)

关于Php Mysql 只回显一半结果,有时甚至没有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42377309/

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