Help with timer
Posted: Fri Oct 29, 2010 1:10 pm
Hi, I have a site where an image changes on a specific hour, this is determined by an SQL database, but for testing purposes, I am just declaring the variable while I am testing different functions.
So, there is an image which is set to buttonoff.png at all times except when the time is a certain time, then it changes to buttonon.png.
I can do this, and have it working nicely, the thing is, I need to make the image stay as button on for only 2 minutes instead of an hour, I need this to happen regardless of refreshing, so even if the user refreshes, that 2 minutes is still goin, I could use a cron job, but I do not know enough about them, anyway, here is the code I have to change the image when it is a specific hour of the day:
As I said, the variable will be taken from an SQL database, but while I am trying to get this to work, I am using a locally declared variable of my choosing.
Any advice would be great.
Thanks
So, there is an image which is set to buttonoff.png at all times except when the time is a certain time, then it changes to buttonon.png.
I can do this, and have it working nicely, the thing is, I need to make the image stay as button on for only 2 minutes instead of an hour, I need this to happen regardless of refreshing, so even if the user refreshes, that 2 minutes is still goin, I could use a cron job, but I do not know enough about them, anyway, here is the code I have to change the image when it is a specific hour of the day:
Code: Select all
<?php
$hour = 15;
if ($hour == date(H))
$buttonimage = "buttonon.png";
else
$buttonimage = "buttonoff.png";
?>
<table width="200" border="1">
<tr>
<td><img src="<?php echo($buttonimage); ?>" /></td>
</tr>
</table>Any advice would be great.
Thanks