gpt4 book ai didi

php - mysqli_fetch 循环不工作

转载 作者:行者123 更新时间:2023-11-30 01:16:16 26 4
gpt4 key购买 nike

我在其他循环中有一个循环不起作用,这是代码:

    while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['rowId'] . "</td>";
echo "<td>" . $row['startDate'] . "</td>";
echo "<td>" . $row['eventName'] . "</td>";
echo "<td>" . $row['betName'] . "</td>";
$string1 = "SELECT * FROM newCell WHERE rowId ='";
$string2 = $row['rowId']."'";
$result2 = $string1.$string2;
echo "<td>" . $result2 . "</td>";

while($row2 = mysqli_fetch_array($result2))
{
echo "<td>" . $row2['odds'] . "</td>";

echo "<td>" . $row2['outcomeName'] . "</td>";
}
echo "</tr>";
}

当我直接在 BBDD 中查询 $result2 以获得第一个结果时,它显示三个结果,但代码不会进入第二个循环。为什么?这里有错误吗?

最佳答案

  while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['rowId'] . "</td>";
echo "<td>" . $row['startDate'] . "</td>";
echo "<td>" . $row['eventName'] . "</td>";
echo "<td>" . $row['betName'] . "</td>";
$string1 = "SELECT * FROM newCell WHERE rowId ='";
$string2 = $row['rowId']."'";
$result2 = $string1.$string2;
echo "<td>" . $result2 . "</td>";

$result2 = mysqli_query($connection, $result2);

while($row2 = mysqli_fetch_array($result2))
{
echo "<td>" . $row2['odds'] . "</td>";

echo "<td>" . $row2['outcomeName'] . "</td>";
}
echo "</tr>";
}

关于php - mysqli_fetch 循环不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19028342/

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