counter

A

Anonymous

Guest
anybody know the script that decrease 1 day itself.
for example, from 365 days to 364 in the next day, then from 364 to 363 in the next day, then from 363 to 362 in the next day, and until 0, then perform some task, after that, set to 365 again.
i want the script that `365` on Jan 1st of any year and then decrement it on each subsequent day till dec 31st, and then reset it on Jan 1st of the next year.
or where's the place can download this script?
thank you!
 
Um. I assume you're going to actually use this number for something. Right? What I gathered from your description is that you want to start with the number 365, decrement it by 1 until it reaches 0, and then reset it to 365 again. Well, to decrement a value, you can just do $val--; .. and to do it repeatedly, just throw it in a loop. And to do it until the end of time.. well, put it in another loop.

Code:
<?
   while(true) {
      for($i = 365; $i > 0; $i--) {
         echo $i . "<br />\n";
      }
   }
?>

The above code will print the numbers from 365 in reverse order until it reaches 0, at which time it will start over. The question is, what in the hell does this accomplish?
 
when i run test9.php, it shows this error message:
Parse error: parse error in c:\phpweb/test9.php on line 3
am i need to create another file to store it??? :?:
this is to check test9.php & make sure it runs once a year

Code:
<? 
if(file_exists('test9.php') {  
  $outfile = fopen('test9.php','r');  
  $lastrun = chop(fgets($outfile));  
} else {  

  $lastrun = 0;  
}  

if(($lastrun + (60 * 60 * 24 * 365)) < time()) {  

  if($outfile = fopen('test9.php','w')) {  
    $now = time() . "\n";  
    fwrite($outfile,$now);  
  } else {  

    echo "Could not log run time, script will rerun next time it is loaded.\n";  
  } 
} 
?>
 
Next time, double-check the code on the line specified before posting. Your error was very simple -- you just forgot a right-parenthese:

Code:
if(file_exists('test9.php')  {
// missing parenthese -----^
 
what's the problem now?
Warning: Wrong parameter count for fgets() in c:\phpweb/test9.php on line 5

Code:
<?

if(file_exists('test9.php')) { 
  $outfile = fopen('test9.php','r'); 
  $lastrun = chop(fgets($outfile)); 
} else { 
  
  $lastrun = 0; 
} 

if(($lastrun + (60 * 60 * 24 * 365)) < time()) { 
   
  if($outfile = fopen('test9.php','w')) { 
    $now = time() . "\n"; 
    fwrite($outfile,$now); 
  } else { 
    
    echo "Could not log run time, script will rerun next time it is loaded.\n"; 
  }  
} 
?>
 
Back
Top