I have a script that tells the user when something is about to expire in the database, so for instance if something expires on the 20th april, and today is the 15th, then it will tell the user there are 5 days left until it expires.
Now i want to add to my script to say if there are 7 days or less till expire date, then show a red coloured div, else if there are less than 30 days but more than 7, show a yellow coloured div, and otherwise if there are more than 30 days left till something expires, show a green coloured div.
can someone please show me what i could do, thanks
<?php
include 'config.php';
$data = mysql_query("SELECT TIMESTAMPDIFF(DAY, insurance_date, NOW()) AS expire_date
FROM supplier_stats") or die(mysql_error());
?>
<?php
include 'config.php';
$result = mysql_query("SELECT TIMESTAMPDIFF(DAY, insurance_date, NOW()) AS expire_date
FROM supplier_stats") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$days = $row['expire_date'] -1;
if ($days > 0)
{
echo "<p>Insurance expires in <font color=\"red\">{$row['expire_date']} day(s)!</font></p>";
}
else
{
$when = $days*-1;
echo "<p>Insurance expires";
if ($when > 1){
echo " in {$when} days</p>";
}
elseif ($when ===1)
{
echo " tomorrow</p>";
}
elseif ($when > 0)
{
echo " today</p>";
}
}
}
?>