我有一個網頁,我把4個簡單的日曆顯示未來4個月的日期。我已經得到了顯示當前月份的代碼,但我不確定如何編輯代碼以顯示第二,第三和第四個月。以下是我用來查找當前月份的代碼:下個月PHP日曆
<table>
<?php
$today = date("d"); // Current day
$month = date("m"); // Current month
$year = date("Y"); // Current year
$days = cal_days_in_month(CAL_GREGORIAN,$month,$year); // Days in current month
$lastmonth = date("t", mktime(0,0,0,$month-1,1,$year)); // Days in previous month
$start = date("N", mktime(0,0,0,$month,1,$year)); // Starting day of current month
$finish = date("N", mktime(0,0,0,$month,$days,$year)); // Finishing day of current month
$laststart = $start - 1; // Days of previous month in calander
$counter = 1;
$nextMonthCounter = 1;
if($start > 5){ $rows = 6; }else {$rows = 5; }
for($i = 1; $i <= $rows; $i++){
echo '<tr class="week">';
for($x = 1; $x <= 7; $x++){
if(($counter - $start) < 0){
$date = (($lastmonth - $laststart) + $counter);
$class = 'class="blur"';
}else if(($counter - $start) >= $days){
$date = ($nextMonthCounter);
$nextMonthCounter++;
$class = 'class="blur"';
}else {
$date = ($counter - $start + 1);
if($today == $counter - $start + 1){
$class = 'class="today"';
}
}
echo '<td '.$class.'><a class="date">'. $date . '</a></td>';
$counter++;
$class = '';
}
echo '</tr>';
}
?>
</table>
需要更改哪些變量才能使其適用於未來幾個月?
您必須瞭解該代碼或至少嘗試理解。你也可以付錢去改變它。 –
@ElonThan我明白這一點。我知道一些簡單的事情,比如將一些變量改爲月+ 1或類似的東西,但我不能確切地知道它在哪裏,網上沒有很多教程 – user2737457