Well, I'm thinking - move forward 6 months - but only ever show 6 months at one time -
I will most likely use a previous <-> forward link rather than dropdown.
Andy
if((isset($_REQUEST["year_month"])) && (!empty($_REQUEST["year_month"])) ){
$date_bits=explode("-",$_REQUEST["year_month"]); # 0=year, 1=month
define("START_YEAR", $date_bits[0]);
define("START_MONTH", $date_bits[1]);
//$this_block = $date_bits[2];
}else{
define("START_YEAR", date('Y'));
define("START_MONTH", date('m'));
}
$the_months = array();
$j = 0;
$this_year = START_YEAR;
$this_month = START_MONTH;
$num_months_shown=0;
while($num_months_shown<MONTHS_TO_SHOW){
// start new year and reset month numbers
if($this_month>12){
$this_month = $this_month-12; # remove full 12 months from cal num
$this_year = $this_year+1; # add 1 to current year
}
$this_month=sprintf("%02s",$this_month); # add 0 if less that 10
$the_months[$this_month]=array("year"=>$this_year,"month"=>$this_month);
++$num_months_shown;
++$this_month;
}
// define LAST block - START
$last_month_start = (START_MONTH-MONTHS_TO_SHOW); # remove months_to_show x 2 to go back this block and then 1 more
$last_year_start = START_YEAR;
if($last_month_start<0){
$last_month_start=$last_month_start+12;
--$last_year_start;
}
$last_month_start=sprintf("%02s",$last_month_start);
// define NEXT block - START
$next_month_start = $this_month; # just use MONTH number that the loop has ended on
$next_year_start = $this_year; # just use YEAR number that the loop has ended on
if($next_month_start>12){
$next_month_start=$next_month_start-12;
++$next_year_start;
}
$next_month_start=sprintf("%02s",$next_month_start);
<a href="calendar.php?id_item=<?php echo ID_ITEM; ?>&year_month=<?php echo $last_year_start; ?>-<?php echo $last_month_start; ?>">prev</a>
<a href="calendar.php?id_item=<?php echo ID_ITEM; ?>&year_month=<?php echo $next_year_start; ?>-<?php echo $next_month_start; ?>">next</a>
<a href="calendar.php?id_item=<?php echo ID_ITEM; ?>&year_month=<?php echo $last_year_start; ?>-<?php echo $last_month_start; ?>">prev</a>
<a href="calendar.php?id_item=<?php echo ID_ITEM; ?>&year_month=<?php echo $next_year_start; ?>-<?php echo $next_month_start; ?>">next</a>
<a href="calendar.php?id_item='.ID_ITEM.'&year_month='.$last_year_start.'-'.$last_month_start.'">prev</a>
<a href="calendar.php?id_item='.ID_ITEM.'&year_month='.$next_year_start.'-'.$next_month_start.'">next</a>
Users browsing this forum: No registered users and 2 guests