为什么我的数组由于mysqli_fecth
数组而出错?我可以对代码进行的处理是正确的,因为我是一个初学者。我将代码更改为mysqli_fetch_assoc(),但错误相同。
这是我做的代码:
<?php
$query = mysqli_query($con,"SELECT t.po_nomor, p.nama_supplier, p1.nama_barang , t.total FROM
(SELECT t1.po_nomor, (SUM(t1.jumlah)-SUM(COALESCE(t4.terima,0))over(PARTITION by t4.refrence) ) as total
FROM pengiriman_supply t1
INNER JOIN data_supplier t2 ON t1.idsupplier = t2.id_supplier
INNER JOIN data_barang t3 ON t1.idbarang = t3.idbarang
LEFT JOIN masuk t4 ON t4.refrence = t1.po_nomor
where t1.tanggal BETWEEN date_sub(curdate(), interval 120 day) AND curdate()
group by t1.po_nomor,t4.po_nomor) t
INNER JOIN pengiriman_supply s ON s.po_nomor = t.po_nomor
INNER JOIN data_supplier p ON s.idsupplier = p.id_supplier
INNER JOIN data_barang p1 ON s.idbarang = p1.idbarang
GROUP BY t.po_nomor
ORDER by t.po_nomor DESC;");
$no = 0;
while($data = mysqli_fetch_array($query)){
$no++;
?>
<tr>
<td><?= $no ?></td>
<td><?= $data['po_nomor'] ?></td>
<td><?= $data['nama_supplier'] ?></td>
<td><?= $data['nama_barang'] ?></td>
<td><?= $data['total'] ?></td>
</tr>
<?php
}
?> </tbody>
在这里我可以更改代码。
最佳答案
您尝试将其粘贴到您的sql命令中,如果它不起作用,则说明她内部有问题。
SELECT t.po_nomor, p.nama_supplier, p1.nama_barang , t.total FROM
(SELECT t1.po_nomor, (SUM(t1.jumlah)-SUM(COALESCE(t4.terima,0))over(PARTITION by t4.refrence) ) as total
FROM pengiriman_supply t1
INNER JOIN data_supplier t2 ON t1.idsupplier = t2.id_supplier
INNER JOIN data_barang t3 ON t1.idbarang = t3.idbarang
LEFT JOIN masuk t4 ON t4.refrence = t1.po_nomor
where t1.tanggal BETWEEN date_sub(curdate(), interval 120 day) AND curdate()
group by t1.po_nomor,t4.po_nomor) t
INNER JOIN pengiriman_supply s ON s.po_nomor = t.po_nomor
INNER JOIN data_supplier p ON s.idsupplier = p.id_supplier
INNER JOIN data_barang p1 ON s.idbarang = p1.idbarang
GROUP BY t.po_nomor
ORDER by t.po_nomor DESC;
关于php - mysqli_fetch_array()中的警告,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59297406/