0 AND itm_stk.ohc_type_id = ? AND itm_stk.item_stock_id NOT IN (SELECT item_stock_id FROM cleanup_item_stock) AND DATE(expiry_date) <= (CURDATE() + INTERVAL ? DAY)"; $stmt = mysqli_prepare($conn, $sql_expiry_items); if (!$stmt) { error_log("Error preparing statement: " . mysqli_error($conn)); die(); } $ohc_id = $_SESSION['current_ohcttype']; $expiryAlertAdvance = getConfigKey("ITEM_EXPIRY_ALERT_DAYS"); if ($expiryAlertAdvance == null) { $expiryAlertAdvance = 90; } mysqli_stmt_bind_param($stmt, "ss", $ohc_id, $expiryAlertAdvance); mysqli_stmt_execute($stmt); $result = mysqli_stmt_get_result($stmt); if ($result) { while ($row = mysqli_fetch_assoc($result)) { $data[] = $row; // Append each row to the data array } } else { error_log("Error executing statement: " . mysqli_error($conn)); } // error_log('near expiring'); echo json_encode($data);