嵌套 while 循环未按预期工作


Nested while loop is not working as expected

我在php中遇到了问题。我尝试显示所有数据,然后将它们放在嵌套循环中。但第二个循环仅返回 null。我不知道我做错了什么。

<?php
ini_set('max_execution_time', 36000); 
$con=mysqli_connect("localhost","root","XXX","YahooFin");
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"show tables from yahooFin where not tables_in_yahooFin = 'nasdaqCompanyList' and not tables_in_yahooFin = 'companylist'");
while($row = mysqli_fetch_array($result)) {
    $result2 = mysqli_query($con, "select * from ".$row['Tables_in_yahoofin']." where entry_date = '2013-06-03'order by entry_date asc limit 1");
    while ($row2 = mysqli_fetch_array($result2));  //<== This line gives me null
    {
        var_dump( $row2);
        echo "<br>";
    }
}
var_dump($row);
mysqli_close($con);
?>
有一个

额外的;分号,不应该在你的循环之后出现

    while ($row2 = mysqli_fetch_array($result2));  //<== This line gives me null
                                              //^ remove this one

此外,您可能有一个拼写错误tables_in_yahooFin在第一个查询中使用Tables_in_yahoofin而在第二个查询中使用。