我想使用以下內容:PHP分配mysql_fetch_array(數據)到一個數組變量
$row1 = mysql_fetch_array($genDay[0][0]);
$row2 = mysql_fetch_array($genDay[0][1]);
$row3 = mysql_fetch_array($genDay[0][2]);
$row4 = mysql_fetch_array($genDay[0][3]);
$row5 = mysql_fetch_array($genDay[0][4]);
$row6 = mysql_fetch_array($genDay[0][5]);
$row7 = mysql_fetch_array($genDay[0][6]);
$row8 = mysql_fetch_array($genDay[1][0]);
$row9 = mysql_fetch_array($genDay[1][1]);
$row10 = mysql_fetch_array($genDay[1][2]);
$row11 = mysql_fetch_array($genDay[1][3]);
$row12 = mysql_fetch_array($genDay[1][4]);
$row13 = mysql_fetch_array($genDay[1][5]);
$row14 = mysql_fetch_array($genDay[1][6]);
像這樣:
$row[$q] = mysql_fetch_array($genDay[$g][$x]);
最終我想使用此呼應結果如下:
<?php echo $row[0]['SUM(itemQty)']; ?>
哪個行不通。
UPDATE 這裏是我使用的時刻哪個的代碼:
$dayD = array("MonD","TueD","WedD","ThuD","FriD","SatD","SunD");
$genre = array("Rock","Metal","Alternative","Modern");
$genDay = array(0=>array("Mon","Tue","Wed","Thu","Fri","Sat","Sun"),
1=>array("Mon","Tue","Wed","Thu","Fri","Sat","Sun"),
2=>array("Mon","Tue","Wed","Thu","Fri","Sat","Sun"),
3=>array("Mon","Tue","Wed","Thu","Fri","Sat","Sun"));
$date = strtotime($_POST['fromDate']);
$dayD[0] = date('Y-m-d', strtotime("last Monday", $date));
$monDSTR = strtotime($dayD[0]);
$c=0;
for ($g=0; $g<=3; $g++)
{
$genDay[$g][0] = mysql_query("SELECT SUM(itemQty) FROM product_sales WHERE itemGenre='" . $genre[$g] . "' AND sale_date BETWEEN '" . $dayD[0] . " 00:00:00' AND '" . $dayD[0] . " 23:59:59'");
for ($x=1; $x<=6; $x++)
{
$dayD[$x] = date('Y-m-d', strtotime("+" . $x . " day", $monDSTR));
$genDay[$g][$x] = mysql_query("SELECT SUM(itemQty) FROM product_sales WHERE itemGenre='" . $genre[$g] . "' AND sale_date BETWEEN '" . $dayD[$x] . " 00:00:00' AND '" . $dayD[$x] . " 23:59:59'");
/*
$cell[$c] = mysql_fetch_array($genDay[$g][$x]);
$c++;
*/
}
}
/*echo $cell[0]['SUM(itemQty)'];*/
的 「回波$細胞[0] [ 'SUM(itemQty)'];」在表格單元格中回顯。
代碼是什麼 代碼是填寫週一到週二的表格單元格當天的總銷售額。 其中每一行將是不同的音樂流派。
'$ row'是一個結果。您無法將其他數據庫查詢作爲數組的鍵傳遞,並期望得到結果。什麼是'$ genDay'?什麼是'$ g'和'$ x'?它應該做什麼?請更多的代碼和意圖。 – Seabass