dear,
this code hav 3 loops. my friends say try to convert the three loops to array first. but i donno how? can u help me?
<!--#include file="../header.asp"-->
<html>
<head>
<title>Calendar</title>
</head>
<body bgcolor="#EAEAD5">
<%
dim navmonth,navyear,firstday,leapTestNumbers,leapTest,lastDate,lastMonth,lastYear,nextMonth,nextYear
navmonth = request.querystring("month")
navyear = request.querystring("year")
If navmonth = "" Then
navmonth = Month(Date)
End If
If navyear = "" Then
navyear = Year(Date)
End If
firstday = Weekday(CDate(navmonth & "/" & 1 & "/" & navyear))
leapTestNumbers = navyear / 4
leapTest = (leapTestNumbers) - Round(leapTestNumbers)
If navmonth = 2 Then
If leapTest <> 0 Then
lastDate = 28
Else
lastDate = 29
End If
ElseIf ((navmonth = 4) OR (navmonth = 6) OR (navmonth = 9) OR (navmonth = 11)) Then
lastDate = 30
Else
lastDate = 31
End If
lastMonth = navmonth - 1
lastYear = navyear
If lastMonth < 1 Then
lastMonth = 12
lastYear = lastYear - 1
End If
nextMonth = navmonth + 1
nextYear = navyear
If nextMonth >12 Then
nextMonth = 1
nextYear = nextYear + 1
End If
dim dateCounter,weekCount,DateEnd,DateBegin,firstDate
dateCounter = 1
weekCount = 1
DateEnd = lastDate
DateBegin = firstDate
%>
<table border="1" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center">
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
<td align="left"><a href="calendar.asp?month=<%=lastMonth%>&year=<%=lastYear%>"><%=MonthName(lastMonth)%></a></td>
<td align="center"><%=MonthName(navMonth)%> <%=navyear%></b></font></td>
<td align="right"><a href="calendar.asp?month=<%=nextMonth%>&year=<%=nextYear%>"><%=MonthName(nextMonth)%></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
<table border="1" cellpadding="2" cellspacing="0" bordercolor="#ffffff">
<tr>
<td width=90 align="center"> Sunday</td>
<td width=90 align="center"> Monday</td>
<td width=90 align="center"> Tuesday</td>
<td width=90 align="center"> Wednesday</td>
<td width=90 align="center"> Thursday</td>
<td width=90 align="center"> Friday</td>
<td width=90 align="center"> Saturday</td>
</tr>
<tr>
<%
' Retrieve record from Calendar Table.
sub CalendarEvent()
dim RSEVENT,rsdate,rsbody,conn
Conn = int_Databasepath
Set RSEVENT = Server.CreateObject("ADODB.RecordSet")
RSEVENT.Open "SELECT * FROM Calendar where month(CalDate)='"&navmonth&"'", Conn, 1, 3
Do while NOT RSEVENT.EOF
rsdate = RSEVENT("CalDate")
rsbody = trim(RSEVENT("Subject"))
If (Day(rsdate) = dateCounter) AND (Month(rsdate) = CInt(navmonth)) AND (Year(rsdate) = CInt(navyear)) Then
Response.write rsbody&"<Br>"
End If
RSEVENT.movenext
Loop
RSEVENT.close
end sub
' Retrieve record from Holidays Table.
SUB CalendarHolidays()
dim strConn,objconn,strSQL,objREC,dtSelected
strconn = int_Databasepath
set objconn = server.createobject("adodb.connection")
objconn.open strconn
strsql = "select * from Holidays"
set objrec = objconn.execute(strsql)
do while not objrec.eof
dim rsholday,rsholdesc
rsholday = objrec("FDate")
rsholdesc = trim(objrec("FDESC"))
If (Day(rsholday) = dateCounter) AND (Month(rsholday) = CInt(navmonth)) AND (Year(rsholday) = CInt(navyear)) Then
response.write "<img src='../images/blinkbullet_ani.gif' ALT='"&rsholdesc&"' align='absmiddle'>"
response.write rsholdesc
response.write "<BR>"
end if
objrec.movenext
Loop
objrec.close
END SUB
' Retrieve record from EVENT Table.
sub Events()
dim RSEVT,rsEvtdate,rsEvtbody,conn,adstateopen
Conn = int_Databasepath
Set RSEVT = Server.CreateObject("ADODB.RecordSet")
RSEVT.Open "SELECT * FROM EventMaster where month(FEVENTDATE)='"&navmonth&"'", Conn, 1, 3
Do while NOT RSEVT.EOF
rsEvtdate = RSEVT("FEVENTDATE")
rsEvtbody = trim(RSEVT("FEVENTTITLE"))
If (Day(rsEvtdate) = dateCounter) AND (Month(rsEvtdate) = CInt(navmonth)) AND (Year(rsEvtdate) = CInt(navyear)) Then
Response.write rsEvtbody&"<Br>"
End If
RSEVT.movenext
Loop
'RSEVT.close
end sub
' Get today date and bgcolor.
SUB getTodayDate()
dim todaydate
todayDate =month(now())&"/"&Day(now())&"/"&Year(Now())
if dateSelect = todayDate then
strbgcolor="gold"
else
strbgcolor="#0099ff"
end if
END SUB
'dim conn
dim newdate,dateSelect,strBGCOLOR
Do while weekCount <= 7
dateSelect = navmonth & "/" & dateCounter & "/" & navyear
If (weekCount < firstDay) OR (dateCounter > lastDate) Then
Response.write "<td height=90 bgcolor=#666666> </td>" 'Blank day
else
CALL getTodayDate()
Response.write "<td height=90 valign=top bgcolor="&strbgcolor&"><a href='Calendar.asp?date="&dateSelect&"'>"&dateCounter&"</a><br>"
CALL Events()
CALL CalendarEvent()
CALL CalendarHolidays()
Response.write "</td>"&vbcrlf
dateCounter = dateCounter + 1
end if
weekCount = weekCount + 1
Loop
weekCount = 1
%>
</tr>
<% Do while dateCounter <= lastDate %>
<tr>
<%
Do while weekCount <= 7
dateSelect = navmonth & "/" & dateCounter & "/" & navyear
If dateCounter > lastDate Then
RESPONSE.WRITE "<td height=90 bgcolor=#666666> </td>" 'Blank
else
CALL getTodayDate()
RESPONSE.WRITE "<td height=90 bgcolor="&strBGCOLOR&" valign=top><a href='Calendar.asp?date="&dateSelect&"'>"&dateCounter&"</a><br>"
CALL Events()
CALL CalendarEvent()
CALL CalendarHolidays()
RESPONSE.WRITE "</td>"&vbcrlf
dateCounter = dateCounter + 1
end if
weekCount = weekCount + 1
Loop
weekCount = 1
%>
</tr>
<% Loop %>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>