query($sql);
// $row = $result->fetch_assoc();
// $id= $row['id'];
// $req_id= $row['req_id'];
// $doc_id= $row['doc_id'];
// $temp = $row['temp'];
// $uid = $row['uid'];
// $exp_date = $row['exp_date'];
$sql = "SELECT file_expire.id, file_expire.req_id, file_expire.doc_id, file_expire.temp, file_expire.uid, file_expire.cur_date, file_expire.exp_date
FROM file_expire";
$result = $conn->query($sql);
// Assuming you have already established the database connection and checked for successful query execution
while ($row = $result->fetch_assoc()) {
$id = $row['id'];
$req_id = $row['req_id'];
$doc_id = $row['doc_id'];
// $temp = $row['temp'];
$uid = $row['uid'];
$exp_date = $row['exp_date'];
$temp = './temp_files/Memo No. PMG-2023-016 Early Out on July 07, 2023.pdf';
// Convert date strings to DateTime objects for easy comparison
$current_date = strtotime(date('Y-m-d'));
// Compare the current date with the expiration date
if ($current_date > strtotime($exp_date)) {
// Debugging statements
echo "Current Date: " . date('Y-m-d', $current_date) . "
";
echo "Expiration Date: " . $exp_date . "
";
if (file_exists($temp)) {
echo "File exists: " . $temp . "
";
if (unlink($temp)) {
echo "File deleted successfully.";
} else {
echo "Failed to delete the file.";
}
} else {
echo "File does not exist: " . $temp . "
";
}
}
}
?>