$queryos = "SELECT * FROM OSCSBranch AS a
LEFT JOIN
(SELECT ItemCode AS icode FROM NonFood
) AS q ON a.ItemCode = q.icode
WHERE a.BranchId = '$bid' AND a.BType = 'O' AND DATE(a.BDate) = '$date'";
$osquery = mysqli_query($conn, $queryos);
if(!$osquery)
{
die("QUERY FAILED OS " . mysqli_error($conn));
}
while($row = mysqli_fetch_assoc($osquery)){
$total[$row['ItemCode']] = $row['TotalQuantity'];
}
答案 0 :(得分:1)
似乎某些记录具有相同的'ItemCode'
。
因为$row['ItemCode'] = ....
同一ItemCode
的新数据会一次又一次地替换旧值,因为您获得了175条记录而不是181条
所以你可以这样做: -
或者: -
$total[] = $row['TotalQuantity']; will give you like array(0=>array('name'=>'a',....)....)
或者
$total[$row['ItemCode']][] = $row['TotalQuantity']; //will give you like array('item201'=>array(0=>array(),1=>array(),...),....) (an example)