0) { while ($row = mysqli_fetch_assoc($result)) { $data[$x]['data'] = $row['issued_qty']; $sum += $row['issued_qty']; $data[$x]['color'] = $colors[$x]; $data[$x]['label'] = getTableFieldValue('tbl_items', 'item_name', 'item_id', $row['item_id'], ''); $x ++; } } $total =0; $remaining =0; $query = "select sum(issued_qty) issued_qty from appointment_stock_history "; if (! $result = @mysqli_query($conn,$query)) { exit(mysqli_error($conn)); } if (mysqli_num_rows($result) > 0) { if ($row = mysqli_fetch_assoc($result)) { $total = $row['issued_qty']; } } $data[$x]['data'] = $total-$sum; $data[$x]['color'] = "#eeeeee"; $data[$x]['label'] ='Others'; echo json_encode($data); ?>