Update automatic!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Update automatic!

Post by Goofan »

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:

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
}
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
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: Update automatic!

Post by Goofan »

Got it fixed Sorry to bother you all ...
Post Reply