Ciao, ho trovato su internet un piccolo script in php per un calendario... l'unico problema è che è quadrato... mentre io avrei bisogno che fosse rettangolare cioè non in base ai giorni dal lunedì alla domenica ma in base ai gioni di calendario avendo solo due righe una con i giorni del mese (1,2,3,4,...., 31) e una con i giorni della settimana (L,M,M,G,V,S,D)...
Ho provato a modificar ei paramentri da solo ma dopo molti tentativi (alla cieca) mi sto arrendendo...
Qualcuno sa come modificarlo? Almeo per farlo uscire rettangolare invece che quadrato?
Grazie mille
Ciao
Ho provato a modificar ei paramentri da solo ma dopo molti tentativi (alla cieca) mi sto arrendendo...
Qualcuno sa come modificarlo? Almeo per farlo uscire rettangolare invece che quadrato?
Grazie mille
Ciao
PHP:
<?php
// if ym is set, i.e. somebody clicked on next or previous months link
if(isset($_GET["ym"]))
{
$year = (int)substr($_GET["ym"], 0, 4);
$month = (int)substr($_GET["ym"], 4, 2);
}
else // otherwise take current month & year
{
$month = date("m", mktime(0,0,0,date('m'),1,date('Y')));
$year = date("Y", mktime(0,0,0,date('m'),1,date('Y')));
}
$skip = date("w", mktime(0,0,0,$month,1,$year)); // days to skip in 1 row of week.
$daysInMonth = date("t", mktime(0,0,0,$month,1,$year)); // total number of dates in the month.
$calendar_head = ''; // for calendar head
$calendar_body = ''; // for calendar boday
$day = 1; // For date in calendar
for($i = 0; $i < 6; $i++) // Outer loop for weeks
{
$calendar_body .= '<tr>'; // start row tag
for($j = 0; $j < 7; $j++) // Inner loop for week days
{
if(($skip > 0)||($day > $daysInMonth)) // display blank till 1 day of month or after total numnber of days in that month
{
$calendar_body .= '<td> </td>';
$skip--;
}
else
{
if($j == 0) // if its Sunday then add class holiday
$calendar_body .= '<td class="holiday">'.$day.'</td>';
else // otherwise add day class
$calendar_body .= '<td class="day">'.$day.'</td>';
$day++; // Increment $day
}
} // inner loop closes
$calendar_body .= '</tr>'; // end row tag
} // outer loop closes
// Calendar head section
$calendar_head = '
<tr>
<th colspan="2"><a href="?ym='.date("Ym", mktime(0,0,0,$month-1,1,$year)).'">« Previous Month</a></th>
<th colspan="3">'.date("F, Y", mktime(0,0,0,$month,1,$year)).'</th>
<th colspan="2"><a href="?ym='.date("Ym", mktime(0,0,0,$month+1,1,$year)).'">Next Month »</a></th>
</tr>
<tr>
<th>Sunday</th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
</tr>';
// PHP code for calendar ends
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>A Calendar Built in PHP</title>
<style type="text/css">
#calendar tbody tr{ height:100px; }
#calendar td{ width:100px; }
#calendar th{background-color:#CCCC99;}
.day{ background-color:#CCFFCC; }
.holiday{ background-color:#FFCC66; }
</style>
</head>
<body>
<h2>A Calendar Built in PHP</h2>
<!-- Table to display calendar -->
<table id="calendar" width="710" border="1" cellspacing="0" cellpadding="5">
<thead>
<?php echo $calendar_head; ?>
</thead>
<tbody>
<?php echo $calendar_body; ?>
</tbody>
</table>
<!-- Table to display calendar -->
<p>This the online demo for the blog post <a href="http://rohitsengar.cueblocks.net/">Build Calendar with PHP</a>.<br />© Rohit Singh Sengar <a href="http://rohitsengar.cueblocks.net/">http://rohitsengar.cueblocks.net/</a></p>
</body>
</html>