codice:
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script Language="JavaScript">
// Class Calendar
// Description: Generates a dynamic calendar given a month and year.
// Usage:
// To setup you need to define three stylesheet elements: .caldefault, .calday, .caltoday
// Then create a Calendar object, e.g.,
// var cal = new Calendar(date, month, year, action);
// Where:
// date - day of the month, e.g., 31 for March 31
// month - number representing the month, e.g., 3 for March
// year - e.g., 2001
// action - the name of the function you want called if the user clicks on a day
// This function will be passed with the arguments date, month, year
// When you want to display the calendary, simply call the Show method, e.g.,
// cal.Show();
// Class Methods
function Calendar_GetString()
{
var firstDate = new Date(this.year,this.month,1);
var firstDay = firstDate.getDay();
var monthArg = this.month + 1;
var calStr = "<TABLE BORDER=1 COLS=7>";
calStr += "<TR>";
calStr += "<TD COLSPAN=7 ALIGN=center><SPAN class=caldefault><font size=2>"+Calendar.monthName[this.month].toUpperCase()+" "+this.year+"</font></SPAN></TD>";
calStr += "</TR>";
calStr += "<TR>";
for (var i=0;i<Calendar.dayName.length;i++)
calStr += "<TD ALIGN=center><SPAN class=caldefault><font size=2>"+Calendar.dayName[i]+"</font></SPAN></TD>";
calStr += "</TR>";
var dayCount = 1;
calStr += "<TR>";
for (var i=0;i<firstDay;i++)
calStr += "<TD> </TD>";
//var monthArg = this.month + 1; ----variabile vecchia
for (var i=0;i<this.monthDays[this.month];i++)
{
var styleStr = "calday";
if (dayCount==this.date)
styleStr = "caltoday";
calStr += '<TD ALIGN="center">'+
'<SPAN class="'+styleStr+'"><font size=2><a href="calendario.php3?chiave=teschio&mese='+monthArg+'&anno='+this.year+'&giorno='+dayCount+'">'+
dayCount+'</a></font></SPAN></A></FONT></TD>';
dayCount++;
if ((i+firstDay+1)%7==0&&(dayCount<this.monthDays[this.month]+1))
calStr += "</TR><TR>";
}
var totCells = firstDay+this.monthDays[this.month];
for (var i=0;i<(totCells>28?(totCells>35?42:35):28)-totCells;i++)
calStr += "<TD> </TD>"
calStr += "</TR>";
calStr += "</TABLE>";
return calStr;
}
function Calendar_Show()
{
var calStr = this.GetString();
document.write(calStr);
}
function Calendar(date,month,year,action)
{
// Properties
this.date = date;
this.month = month;
this.year = year;
this.action = action;
this.monthDays = new Array(31,28,31,30,31,30,31,31,30,31,30,3
1);
// Leap year test
if (((this.year % 4 == 0) && (this.year % 100 != 0)) || (this.year % 400 == 0))
this.monthDays[1] = 29;
else
this.monthDays[1] = 28;
// Methods
this.Show = Calendar_Show;
this.GetString = Calendar_GetString;
}
// Static Class Properties
Calendar.dayName = new Array("Dom","Lun","Mar","Mer","Gio","Ven","Sab");
Calendar.monthName = new Array("Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre");
// Class CalendarSet
// Description: Keeps track of multiple calendars and has methods for populating popup fields.
function CalendarSet_Show()
{
var border = '';
document.write('<table border="0" cellpadding="0" cellspacing="0"><tr>');
// Show the top border
for (var i=0;i<this.calendars.length+2;i++)
{
document.write(border);
}
document.write('</tr><tr>');
document.write(border);
for (var i=0;i<this.calendars.length;i++)
{
document.write('<td>');
this.calendars[i].Show();
document.write('</td>');
}
document.write(border);
document.write('</tr><tr>');
// Show the bottom border
for (var i=0;i<this.calendars.length+2;i++)
{
document.write(border);
}
document.write('</tr></table>');
}
function CalendarSet_SetMonthOptions(selectField)
{
var selected = true;
selectField.options.length = 0; // Clear the popup
for (var i=0;i<this.calendars.length;i++)
{
var anOption = new Option(Calendar.monthName[this.calendars[i].month]+" "+this.calendars[i].year,(this.calendars[i].month+1)+","+this.calendars[i].year,selected,selected);
selectField.options[i] = anOption;
selected = false;
}
selectField.options[0].selected = true;
}
function CalendarSet_SetDateOptions(monthSelectFi
eld,dateSelectField)
{
var calObject = this.calendars[monthSelectField.selectedIndex];
var daysInMonth = calObject.monthDays[calObject.month];
if (dateSelectField.options.length==0)
{
var anOption = new Option("Date",0,true,true);
dateSelectField.options[0] = anOption;
}
if (dateSelectField.options.length > daysInMonth+1)
{
// Remove last entries
var excess = dateSelectField.options.length - daysInMonth - 1;
for (var i=0;i<excess;i++)
{
dateSelectField.options[dateSelectField.length-1] = null;
}
}
else if (dateSelectField.options.length < daysInMonth+1)
{
// Add entries
var deficit = daysInMonth - dateSelectField.options.length + 1;
for (var i=0;i<deficit;i++)
{
var anOption = new Option(dateSelectField.options.length,dateSelectField.options.length,false,false);
dateSelectField.options[dateSelectField.options.length] = anOption;
}
}
// Set the default day to current
var now = new Date();
dateSelectField.options[now.getDate()].selected = true;
}
function CalendarSet(startDate,months,action)
{
// Properties
this.borderColor = "#42316B";
this.calendars = new Array();
var now = new Date();
var month=startDate.getMonth();
var year = startDate.getFullYear();
for (var i=0;i<months;i++)
{
var dayToHilite = 0;
if ((now.getFullYear()==year)&&(now.getMonth()==month))
dayToHilite = now.getDate();
this.calendars[i] = new Calendar(dayToHilite,month,year,action);
month++;
if (month>=12)
{
month = 0;
year++;
}
}
// Methods
this.Show = CalendarSet_Show;
this.SetMonthOptions = CalendarSet_SetMonthOptions;
this.SetDateOptions = CalendarSet_SetDateOptions;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">
<?php
$host= "localhost";
$user= "USER";
$password= "PASSWORD";
$dbname= "DBNAME";
$link = mysql_connect ($host, $user, $password);
$tutto = "SELECT * FROM TABELLA";
$query = mysql_db_query ($dbname,$tutto)
or die ( "Non riesco ad eseguire la richiesta $tutto");
$righe = mysql_num_rows ($query);
?>
<script Language="JavaScript">
// Example Calendar Click Handler
function HandleCalClick(day,mon,year)
{
//alert("Got a click on " + mon + "/" + day + "/" + year);
document.write('" + mon + "/" + day + "/" + year');
}
// Setup
var gImageDir = "images/"
// Create calendar objects
var now=new Date();
var gCalendarSet = new CalendarSet(now,1,"HandleCalClick");
gCalendarSet.Show();
</script>
<?
if (isset($chiave)){
$dati=mysql_db_query( "$dbname", "SELECT * FROM TABELLA WHERE CAMPO BETWEEN '%$anno%-%$mese%-%$giorno% 00:00:00' AND '%$anno%-%$mese%-%$giorno% 23:59:59' ORDER BY CAMPO DESC");
while ($row = mysql_fetch_array ($dati)){
$verifica=$row[ "title"];
echo "
Titolo: ".$row[ "title"]. " Oggetto: ".$row[ "oggetto"]. " ";
echo "[ <a href=\"index.php?module=demo&func=display&lid=$row[lid]&pid=$row[cid]\">".VISUALIZZA."</a> ]
";
}
if (!$verifica){
print ( "
Nessuna corrispondenza trovata");
}
mysql_free_result ($dati);
}else{
echo "
Seleziona una data";
}
mysql_free_result ($query);
mysql_close ($link);
?>
</body>
</html>