home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / calendar-2010-08-23.tar.gz / calendar-2010-08-23.tar / calendar / functions / list_years.php < prev    next >
PHP Script  |  2003-10-12  |  1KB  |  32 lines

  1. <?php
  2.  
  3. $year_time = strtotime($getdate);
  4. print "<select name=\"action\" class=\"query_style\" onChange=\"window.location=(this.options[this.selectedIndex].value);\">\n";
  5.  
  6. // Print the previous year options.
  7. for ($i=0; $i < $num_years; $i++) {
  8.     $offset = $num_years - $i;
  9.     $prev_time = strtotime("-$offset year", $year_time);
  10.     $prev_date = date("Ymd", $prev_time);
  11.     $prev_year = date("Y", $prev_time);
  12.     print "<option value=\"year.php?cal=$cal&getdate=$prev_date\">$prev_year</option>\n";
  13. }
  14.  
  15. // Print the current year option.
  16. $getdate_date = date("Ymd", $year_time);
  17. $getdate_year = date("Y", $year_time);
  18. print "<option value=\"year.php?cal=$cal&getdate=$getdate_date\" selected>$getdate_year</option>\n";
  19.  
  20. // Print the next year options.
  21. for ($i=0; $i < $num_years; $i++) {
  22.     $offset = $i + 1;
  23.     $next_time = strtotime("+$offset year", $year_time);
  24.     $next_date = date("Ymd", $next_time);
  25.     $next_year = date("Y", $next_time);
  26.     print "<option value=\"year.php?cal=$cal&getdate=$next_date\">$next_year</option>\n";
  27. }
  28.  
  29. // finish <select>
  30. print "</select>";
  31. ?>
  32.