= '$year-$month-31' ) AND( official_check_date IS NULL OR official_check_date = '' OR official_check_date >= '$year-$month-31' ) "; $sql .= !empty($type) ? " AND contract_type = '$type'" : ""; $sql .= !empty($mtype) ? " AND renovate_type Like '%$mtype%'" : ""; $result = mysqli_query($link, $sql); $data = mysqli_fetch_all($result, MYSQLI_ASSOC); return json_encode($data, JSON_UNESCAPED_UNICODE); }