Hi Guys,
I am lost, and pulling off my hair (at least what is left LOL).
Well, I have a small table that has two dates Calibration Date and Calibration Due Date. Also has a status for Expiration. So user will no use equipment. I would like to have this query done when the page is loaded, not by pressing a button.
I need help in sequence and order of coding.
<?php //expiration method
$cal = strtotime($row["eqcaldate"]);
$cal2 = $row["eqcaldate"];
$actual = date("Y-m-d");
$exp1 = strtotime(date("Y-m-d", strtotime("+700 days", $cal)));
$exp2 = date("Y-m-d", $exp1);
$exp3 = strtotime(date("Y-m-d", strtotime("+730 days", $cal)));
$exp4 = date("Y-m-d", $exp3);
$stat = "";
if ($cal2 = (""))
{$stat = "NO DATA";}
elseif
($exp2 < $actual)
{$stat = "Available";}
elseif
($exp2 <= $actual)
{$stat = "30 Days Warning";}
elseif
($exp3 > $actual)
{$stat = "DO NOT USE - Expired";}
//$row["eqstatus"] = $stat;
if(isset($_POST['hit']))
{
include 'library/config.php';
include 'library/opendb.php';
//$eq_status = $_POST['$stat'];
$query = "INSERT INTO equipment (eqstatus) VALUES ('$stat')";
mysql_query($query) or die('Error, insert query failed');
$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, insert query failed');
include 'library/closedb.php';
echo "Equipment was succesfully added";
}
?>
Also forgot to mention, expiration date is after two years of calibration, but I want a warning before 30days.
thnx!