Hi all,
I hope someone can help...please! I am hitting a brick wall here.
What I have, is a system that takes set inputted occassions and displays them dependant on their expiry date.
So if an occasion is set to expire on a particular date at a particular time, a field in my db is updated from "ACTIVE" (the default) to "EXPIRED".
This is my php:
if (($expdate<=$nowdate) && ($exptime<=$nowtime)) {
$link = mysql_connect("$sqlhost","$sqllogin","$sqlpass") or die(mysql_error());
mysql_select_db("$sqldb",$link) or die(mysql_error());
$query="UPDATE $sqlstandby SET status='EXPIRED' WHERE func_id = '$func_id'" or die(mysql_error());
mysql_query($query) or die(mysql_error());
mysql_close();
} else {
$link = mysql_connect("$sqlhost","$sqllogin","$sqlpass") or die(mysql_error());
mysql_select_db("$sqldb",$link) or die(mysql_error());
$query="UPDATE $sqlstandby SET status='ACTIVE' WHERE func_id = '$func_id'" or die(mysql_error());
mysql_query($query) or die(mysql_error());
mysql_close();
}
This checks to see if the expiry date and expiry time are either older than, or equal to the current date and time, and then updates the 'status' field accordingly. This works if (i.e):
Expiry Date is: 20030714
Expiry Time is: 11:15
...and if (i.e):
Current Date is: 20030715
Current Time is: 12:30
Perfect. BUT... if:
Expiry Date is: 20030714
Expiry Time is: 12:30
...and if (i.e):
Current Date is: 20030715
Current Time is: 11:15
...so the times are the other way around, but the dates are the same, then this function doesn't work - even if the expiry date is in the past, the db is updated as "ACTIVE", because the expiry time is ahead of the current time.
This screws my whole system up. Is there a way to make the db update "EXPIRED" if the expiry date AND expiry time TOGETHER are less than or equal to the current date AND time TOGETHER?
I hope this makes sense - I would really appreciate some help here.
Thanks,
Jonathen