Buongiorno, vorrei modificare uno script ph di un calendario che
mostra solamente il mese corrente.
Vorrei gentilmente con il vostro aiuto inserire i due pulsanti per far scorrere avanti ed indietro
i mesi.
Grazie.
codice:<?php $month = date("n"); $year = date("Y"); $firstDay = mktime(0,1,0,$month,1,$year); $daysInMonth = date("t",$firstDay); $firstDay = date("w",$firstDay); echo "<table width='280' border='1'>\n"; echo "<tr>\n"; echo "<td align='center'>" . date("F Y") . "</td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<td>\n"; echo "<table width='280' border='0' cellspacing='2' cellpadding='2'>\n"; echo "<tr align='center'>\n"; echo "<td width='40'>Sun</td>\n"; echo "<td width='40'>Mon</td>\n"; echo "<td width='40'>Tue</td>\n"; echo "<td width='40'>Wed</td>\n"; echo "<td width='40'>Thu</td>\n"; echo "<td width='40'>Fri</td>\n"; echo "<td width='40'>Sat</td>\n"; echo "</tr>\n"; # Calculate number of rows $totalCells = $firstDay + $daysInMonth; if($totalCells < 36){ $rowNumber = 5; } else { $rowNumber = 6; } $dayNumber = 1; # Create Rows for($currentRow=1; $currentRow <= $rowNumber; $currentRow++){ if($currentRow == 1){ # Create First Row echo "<tr align='center'>\n"; for($currentCell = 0; $currentCell<7; $currentCell++){ if($currentCell == $firstDay){ # First Day of the Month echo "<td width='40'>" . $dayNumber . "</td>\n"; $dayNumber++; } else { if($dayNumber > 1){ # First Day Passed so output Date echo "<td width='40'>" . $dayNumber . "</td>\n"; $dayNumber++; } else { # First Day Not Reached so display blank cell echo "<td width='40'></td>\n"; } } } echo "</tr>\n"; } else { # Create Remaining Rows echo "<tr align='center'>\n"; for($currentCell = 0; $currentCell < 7; $currentCell++){ if($dayNumber > $daysInMonth){ # Days in month exceeded so display blank cell echo "<td width='40'></td>\n"; } else { echo "<td width='40'>" . $dayNumber . "</td>\n"; $dayNumber++; } } echo "</tr>\n"; } } echo "</table>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table>\n"; ?>

Rispondi quotando