Update automatic!
Posted: Wed Oct 03, 2012 1:08 pm
Hi,
I got a "project" going...
And I got stuck hard.
What I'm doing/trying todo:
Update every time I reach the next time stamp.
Untill the next time stamp actually is future from now! And not future from the next time stamp.
Code:
I want to add this to a loop but since I use date's I can't figure it out.
Whatever I try I either accidentally erase the database row or create and infi loop
Please Help me!
Thanks in advance!
Regards,
Thomas
I got a "project" going...
And I got stuck hard.
What I'm doing/trying todo:
Update every time I reach the next time stamp.
Untill the next time stamp actually is future from now! And not future from the next time stamp.
Code:
Code: Select all
$time = date("H:i:s", strtotime ($extraTime)); // Get the current time ($extraTime adds 2 hours)
$dater = date("Y-m-d H:i:s", strtotime ($dC .$tC .$ta)); // Add the next time stamp. (dC = dateComplete (Date for completion), tC = timeComplete(Time for completion), ta = add additional time (future).
$timef = date("H:i:s", strtotime ($dater)); //Get the Hour, Min, Seconds
$datef = date("Y-m-d", strtotime ($dater));//Get the Year, Month, Day
$equal = strcmp($datef, $dC); //Compare Current date with target date
if ($time >= $tC && $equal == 0){ //if both time and date is a target and has not yet happend ->
$lvl++; //add to development lvl
$mydb = "UPDATE my_research SET lvl= '" .mysql_real_escape_string($lvl) ."',
timeComplete= '" .mysql_real_escape_string($timef) ."',
dateComplete= '" .mysql_real_escape_string($datef) ."'
WHERE id= '" .mysql_real_escape_string($id) ."' ";
$db->dbquery($mydb); //Update the database
}
Whatever I try I either accidentally erase the database row or create and infi loop
Thanks in advance!
Regards,
Thomas