1

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

<?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);
?>
4

1 回答 1

3

;循环后不应该有一个额外的分号

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

另外,您可能tables_in_yahooFin在第一个查询中使用了错字,而Tables_in_yahoofin在第二个查询中使用了错字。

于 2013-06-05T17:25:28.073 回答