我有數據庫連接。我想創建一個數組,但是我認爲有些問題是問題。這裏是我的陣列碼:從數據庫MySQL製作數組
$var = "SELECT SUBSTRING(KayitTarihi,1,4) AS year,SUBSTRING(KayitTarihi,6,2) AS month,SUBSTRING(KayitTarihi,9,2) AS day,SUBSTRING(KayitTarihi,12,2) AS saat,SUBSTRING(KayitTarihi,15,2) AS dakika,Guc FROM Urun WHERE Date(KayitTarihi)=\"".$link_m."\"";
$result = $mysqli->query($var);
$data = array();
foreach ($result as $row) {$data[] = $row;}
print_r($data);
$no=1;$total_deger=count($data);
echo $total_deger;
for($i=0;$i<$total_deger);$i++){
$xxx[i]="[Date.UTC(".$data[i]['year'].",".$data[i]['month'].",".$data[i]['day'].",".$data[i]['saat'].",".$data[i]['dakika'].",00),".$data[i]['Guc']."]";if($no < $total_deger){echo ",";}
echo $xxx[i];
}
當我運行這段代碼,什麼都不會發生在頁。當我寫信給我例如0。我可以看到我的數組值。我在哪裏錯誤?
語法錯誤: - for($ i = 0; $ i <$ total_deger); $ i ++){'檢查額外支架?這是TYPO嗎? –
是的,現在沒事了..謝謝。但是現在我的$ no = 1,並且我有if語句$ no <$ total_deger。 $ total_deger是23.但它看起來像$ no <$ total_deger,我的if語句是真的。哪裏不對? – catcher
也'回聲$ XXX [I]'應該是'回聲$ XXX [$ i];'**看看你的PHP錯誤日誌預期當事情不工作** – RiggsFolly