I have created a mysql table as shown below.
I would like to compare the dates in the table with the current date by using if else statement, and send notifications to the user one day before, one day after and one the same date
For instance, let's say today's date is 18/10, and expiry date for Milk is 20/10, so I want to send notifications on 19th, 20th, and 21st.
So, if you can help me with comparison code and the code for sending notification (such as email) that should be under if statement I would really appreciate it :).
My question might seem easy but I am new to php I do not have much information about it.
Here is my php code that I am trying to do
<?php
$first= new Carbon;
//$second= here I want the date to be collected from date column in the database
//X= The name of the item that will be collected from database (Item_Name) column
if ($second=eq($first+1))
{echo"X is going to expire tomorrow"}
// instade of dispaying the above sentence, i want it to be sent as email
if ($first=eq($second))
{echo"X is going to expire today!!"}
if ($first>eq($second))
{echo"X has EXPIRED already"}
?>
My table:
ID Item_Name Expiry_Date
1 Milk 2017-10-20
2 Chicken 2017-10-22
3 Meat 2017-10-25