我一直在試圖得到一系列嵌套循環工作從一個表中選擇數據庫名稱,然後查詢該數據庫中選定的表,並將結果相加,並顯示它們的數量和數據庫名稱。嵌套雖然循環php
我得到的代碼工作,但它持續顯示:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
我已經想盡辦法,我發現在網上幫,但沒有工作。
$resulta = mysql_query("SELECT dbname AF012 FROM Customer");
while($data = mysql_fetch_array($resulta))
{
$db = $data[' dbname '];
$result = null;
$result2 = mysql_query("SELECT changemade FROM $db.orders");
//looping through the results
while($row = mysql_fetch_array($result2))
{
//checking if any record is 1,2 or 3
if(($row[‘changemade’]== 1) || ($row[‘changemade’]== 2) || ($row[‘changemade’]== 3)) {
//if any match the if adding 1 to the counter
$counter ++;
}
}
unset($result2);
echo $db." ".$counter;
echo "<br>";
$counter = 0;
$result = null;
$result2 = null;
}
所有的數據庫連接都可以正常工作,所以它與此無關。任何幫助都會很棒。
你有一大堆的彎撇號,而不是真正的單引號'$行[「changemade」] == 1)'應該是'$行[「changemade」] = = 1)' – 2012-04-11 13:25:15
我需要查看客戶表的模式。 – wachpwnski 2012-04-11 13:29:02