|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can anyone help me with a timer?
Hello, i've just learned basic PHP for this script I needed for my page. Im pretty much finished, except for the most important aspect.
I need one of my variables to increase by 1 every day at a cirtain time automatically (Or have a timer increase it every 24 hours) Any help would be much apreciated, thanks |
|
#2
|
|||
|
|||
|
RE: Can anyone help me with a timer?
Have a variable increase every day at a certain time? Is this a script you are running from a command line and it runs in a constant loop? If not, variables get reset every time a script is run.
Explain what exactly you are trying to accomplish here and I'm sure we can figure something out... |
|
#3
|
|||
|
|||
|
RE: Can anyone help me with a timer?
ok i dont really know what im doing. I will explain what im trying to do.
Im starting up a little web comic, and im writing an uptator script for it. So far what it does is it makes next/previous buttons work, adds the apropriate image for each day, and when it gets to the $today value, it stops going forward. So of course I $today to increase by 1 value every day so that it updates automatically. I assumed this could be done in PHP... If not does anyone have any other suggestions? |
|
#4
|
|||
|
|||
|
RE: Can anyone help me with a timer?
I wouldn't try to increase the variable each day. Instead, I'd rely on the date() function.
For example, you could create an array and use a while loop, and then populate the array based on date. First name your comics for each day, like this: comic0425.jpg comic0426.jpg etc... Then, if the comic array is called "comicarray,": --------------------------------- $day = date("d"); //gets day $month = date("m"); //gets month $inserter = "1"; //pace variable while ($inserter <= $day) { //sets name of comic $add = "comic" . $month . $day . ".jpg"; //adds comic to array $comicarray[] = $add; //increase pace, runs again $inseter++; } ---------------------------- now you have array to work with. And you can echo each item of the array as a link or as an image... -Adam |
|
#5
|
|||
|
|||
|
RE: Can anyone help me with a timer?
ah! I didnt even know about the date() function (Like i said i really dont know what im doing)
Thank you very much for your help, i will experiment and get it working now i think =) |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Can anyone help me with a timer? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|