1

私はphpに問題があります。すべてのデータを表示してから、ネストされたループに入れようとしました。しかし、2 番目のループは 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);
?>
4

1 に答える 1

3

;ループの後にあるべきではない余分なセミコロンがあります

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

また、タイプミスtables_in_yahooFinが最初のクエリTables_in_yahoofinで使用され、2 番目のクエリで使用されている可能性があります。

于 2013-06-05T17:25:28.073 に答える