0) { while ($row_stock_item_selected = mysqli_fetch_assoc($result_stock_item_selected)) { //extract($row); array_push($data, $row_stock_item_selected); } } } $sql_stock_item="select * from item_stock where item_id='".$_POST['item_id']."' and item_batch_no!='' and stock_qty>0 and ohc_type_id='" . $ohc_id . "' $selected_batch order by expiry_date " ; error_log('treatent_batch'.$sql_stock_item); if (!$result_stock_item = @mysqli_query($conn,$sql_stock_item)) { exit(mysqli_error($conn)); } if(mysqli_num_rows($result_stock_item) > 0) { while ($row_stock_item = mysqli_fetch_assoc($result_stock_item)) { //extract($row); if($row_stock_item['expiry_date']!="0000-00-00" && $row_stock_item['expiry_date']!="" && $row_stock_item['expiry_date']!=null){ $date= date('Y-m-d', strtotime($row_stock_item['expiry_date'])) ; $date_today= date("Y-m-d"); if($date>=$date_today){ array_push($data,$row_stock_item); } }else{ array_push($data,$row_stock_item); } } } echo json_encode($data);