php loop is skipping or missing some results of mysql query, the same query is bringing 181 results in PhpMyAdmin and even in sqlYOG where as the loop is bringing only 175
$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'];
}
It seems like some records have same
'ItemCode'
.So due to
$row['ItemCode'] = ....
the new data of same
ItemCode
is replacing the older value again and again and due to that you are getting 175 record instead of 181So you can do it like below:-
Either:-
Or