jeff ward
12-26-2006, 08:13 AM
Im trying to make a basic calendar. everything works except for one thing, it will not display data to the 1st day of each month. All other days work perfect, does anyone have any ideas on what ive got wrong?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Calendar</title>
<link rel="stylesheet" type="text/css"
href="/css/mystyles.css">
<style type="text/css">
<%
print = request.querystring("print")
if print = 1 then %>
.printstyle {
border-top: thin solid gray;
border-right: thin solid gray;
}
<% end if %>
input,button,textarea
{
font-size: 13px;
color: black;
font-family: Arial, Helvetica, sans-serif;
border: 1px #bbbbbb solid;
}
input[type=submit],input[type=button],input[type=reset],button
{
margin:1px;
padding:1px;
cursor: pointer;
cursor: hand;
}
input[type=image]
{
cursor: pointer;
cursor: hand;
border: 0px #bbbbbb none;
}
select
{
font-size: 11px;
color: #336633;
font-family: Arial, Helvetica, sans-serif;
border: 1px #bbbbbb solid;
}
.indent
{
margin-left:10px;
width: 550px;
}
.indent15
{
margin-left:15px;
}
.redtext
{
color: red;
font-weight: bold;
}
.tableHeader
{
text-align:center;
background-color:#dddddd;
padding-top:2px;
font-size:12px;
font-weight: bold;
color:#666666;
}
td
{
font-size: 13px;
}
.verd {
font-family:verdana;
}
.style1 {
color: #CCCCCC;
font-weight: bold;
}
</style>
<%
dbpath = server.mappath("cal.mdb")
sub closers
rs.Close
set rs = nothing
end sub
sub closeconn
conn.close
set conn = nothing
end sub
FUNCTION PreSubmit2(p_sTargetString)
PreSubmit2 = REPLACE(p_sTargetString,"textarea","")
PreSubmit2 = REPLACE(PreSubmit2,"'","'")
PreSubmit2 = REPLACE(PreSubmit2,"""",""")
PreSubmit2 = REPLACE(PreSubmit2,"<","<")
PreSubmit2 = REPLACE(PreSubmit2,">",">")
PreSubmit2 = Trim(PreSubmit2)
END FUNCTION
%>
</head>
<%
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'from exJune.com/scripts/calendar.asp
goDate=Request.QueryString("goDate")
if goDate<>"" then
goDate=Request.QueryString("goDate")
else
goDate=Request.Form("goDate")
if goDate<>"" then
goDate=Request.Form("goDate")
else
goDate=date()
end if
end if
if not isdate(godate) then
response.write ("<p>invalid date!</p>")
response.end
end if
goDateMonth=month(goDate)
goDateDay=day(goDate)
goDateYear=year(goDate)
goDateFirst=goDateMonth&"/1/"&goDateYear
goDateFirstWeekday=Weekday(goDateFirst)
goDateNextMonth=DateAdd("m",1,goDateFirst)
goDateTotalDays=DateDiff("d",goDateFirst,goDateNextMonth)
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
godatelast = goDateMonth & "/" & goDateTotalDays & "/" & goDateYear
MainSQL = "Select ID,eventdate,eventtime,eventname,eventdesc from tblcalendar where eventdate between # " & godatefirst & "# AND #" & godatelast & "# AND active = 1 order by eventdate,eventtime;"
set Conn = server.createobject("adodb.connection")
Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
Set RS = Server.CreateObject("ADODB.recordset")
RS.Open mainSQL, Conn, 1, 3
recordcount = rs.recordcount
if recordcount > 0 then
eventnumber = "<div>" & recordcount & " events from " & godatefirst & " - " & godatelast & "</div>"
data = RS.GetRows()
iRecFirst = LBound(data, 2)
iRecLast = UBound(data, 2)
else
eventnumber = "<div style='verd'>No Events Found</span>"
end if
rs.Close
set rs = nothing
conn.close
set conn = nothing
%>
<body>
<!-- #include virtual="header_files/header.asp" -->
<% if print <> 1 then %>
<div align="center" class='verd'><%=eventnumber%> <small> [<a href="default.asp">calendar admin</a>]</small>
</div>
<% end if %>
<table width="99%" height="90%" border="0" cellspacing="1" cellpadding="3" align="center" class="verd">
<tr bgcolor="#C0C0C0">
<td colspan="7"><div align="center">
<a href="?goDate=<%=DateAdd("m",-1,goDate)%>" title='previous month'><<</a>
<% =MonthName(goDateMonth) %> - <% =goDateYear %>
<a href="?goDate=<%=DateAdd("m",1,goDate)%>" title='next month'>>></a></div></td>
</tr>
<tr bgcolor="#000000">
<td align="center" class="style1" width="14%">S</td>
<td align="center" class="style1" width="14%">M</td>
<td align="center" class="style1" width="14%">T</td>
<td align="center" class="style1" width="14%">W</td>
<td align="center" class="style1" width="14%">T</td>
<td align="center" class="style1" width="14%">F</td>
<td align="center" class="style1" width="14%">S</td>
</tr>
<tr>
<%weekdayCell=1%>
<%'+++ empty days +++%>
<%i=1%>
<%do while i<goDateFirstWeekday %>
<td><% if weekdayCell=1 then %> <img src="" width="1" height="80" align="texttop" />
<%end if%></td>
<%i=i+1%>
<%weekdayCell=weekdayCell+1%>
<%loop%>
<%'++++++++++++++++++%>
<%'+++ month days +++%>
<%wday=0%>
<%cellDate=goDateFirst%>
<%do while wday<goDateTotalDays %>
<td valign="top" bgcolor="#F9F9F9" class="printstyle" style="vertical-align: top;">
<a href="?goDate=<%=cellDate%>" style='text-decoration: none; color: red;' title="<%=cellDate%>"><%=day(cellDate)%></a>
<% if weekdayCell=1 then %><img src="" width="1" height="80" align="texttop" /><%end if%>
<%
if recordcount > 0 then
count = 0
For I = iRecFirst To iRecLast
id = data(0,I)
eventdate = data(1,I)
eventtime = data(2,I)
eventname = data(3,I)
eventdesc = data(4,I)
if celldate = eventdate then
'display a divider if there is more than 1 record per day.
count = count + 1
if count > 1 then
response.write "<hr style='height: 1px; color: gray' width='50%'>"
end if
response.write "<small class='verd'>" & eventtime & "-" & eventname & "</small>"
end if
Next
end if
%>
</td>
<% if weekdayCell=7 then %>
</tr>
<tr>
<%
weekdayCell=1
else
weekdayCell=weekdayCell+1
end if
%>
<% cellDate=DateAdd("d",1,cellDate)
%>
<%wday=wday+1%>
<%loop%>
</tr>
</table>
<% if print <> 1 then %>
<p class="verd"><a href="?godate=<%=godate%>&print=1">Print Format</a></p>
<% end if %>
<!-- #include virtual="include/footer.asp" -->
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Calendar</title>
<link rel="stylesheet" type="text/css"
href="/css/mystyles.css">
<style type="text/css">
<%
print = request.querystring("print")
if print = 1 then %>
.printstyle {
border-top: thin solid gray;
border-right: thin solid gray;
}
<% end if %>
input,button,textarea
{
font-size: 13px;
color: black;
font-family: Arial, Helvetica, sans-serif;
border: 1px #bbbbbb solid;
}
input[type=submit],input[type=button],input[type=reset],button
{
margin:1px;
padding:1px;
cursor: pointer;
cursor: hand;
}
input[type=image]
{
cursor: pointer;
cursor: hand;
border: 0px #bbbbbb none;
}
select
{
font-size: 11px;
color: #336633;
font-family: Arial, Helvetica, sans-serif;
border: 1px #bbbbbb solid;
}
.indent
{
margin-left:10px;
width: 550px;
}
.indent15
{
margin-left:15px;
}
.redtext
{
color: red;
font-weight: bold;
}
.tableHeader
{
text-align:center;
background-color:#dddddd;
padding-top:2px;
font-size:12px;
font-weight: bold;
color:#666666;
}
td
{
font-size: 13px;
}
.verd {
font-family:verdana;
}
.style1 {
color: #CCCCCC;
font-weight: bold;
}
</style>
<%
dbpath = server.mappath("cal.mdb")
sub closers
rs.Close
set rs = nothing
end sub
sub closeconn
conn.close
set conn = nothing
end sub
FUNCTION PreSubmit2(p_sTargetString)
PreSubmit2 = REPLACE(p_sTargetString,"textarea","")
PreSubmit2 = REPLACE(PreSubmit2,"'","'")
PreSubmit2 = REPLACE(PreSubmit2,"""",""")
PreSubmit2 = REPLACE(PreSubmit2,"<","<")
PreSubmit2 = REPLACE(PreSubmit2,">",">")
PreSubmit2 = Trim(PreSubmit2)
END FUNCTION
%>
</head>
<%
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'from exJune.com/scripts/calendar.asp
goDate=Request.QueryString("goDate")
if goDate<>"" then
goDate=Request.QueryString("goDate")
else
goDate=Request.Form("goDate")
if goDate<>"" then
goDate=Request.Form("goDate")
else
goDate=date()
end if
end if
if not isdate(godate) then
response.write ("<p>invalid date!</p>")
response.end
end if
goDateMonth=month(goDate)
goDateDay=day(goDate)
goDateYear=year(goDate)
goDateFirst=goDateMonth&"/1/"&goDateYear
goDateFirstWeekday=Weekday(goDateFirst)
goDateNextMonth=DateAdd("m",1,goDateFirst)
goDateTotalDays=DateDiff("d",goDateFirst,goDateNextMonth)
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
godatelast = goDateMonth & "/" & goDateTotalDays & "/" & goDateYear
MainSQL = "Select ID,eventdate,eventtime,eventname,eventdesc from tblcalendar where eventdate between # " & godatefirst & "# AND #" & godatelast & "# AND active = 1 order by eventdate,eventtime;"
set Conn = server.createobject("adodb.connection")
Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
Set RS = Server.CreateObject("ADODB.recordset")
RS.Open mainSQL, Conn, 1, 3
recordcount = rs.recordcount
if recordcount > 0 then
eventnumber = "<div>" & recordcount & " events from " & godatefirst & " - " & godatelast & "</div>"
data = RS.GetRows()
iRecFirst = LBound(data, 2)
iRecLast = UBound(data, 2)
else
eventnumber = "<div style='verd'>No Events Found</span>"
end if
rs.Close
set rs = nothing
conn.close
set conn = nothing
%>
<body>
<!-- #include virtual="header_files/header.asp" -->
<% if print <> 1 then %>
<div align="center" class='verd'><%=eventnumber%> <small> [<a href="default.asp">calendar admin</a>]</small>
</div>
<% end if %>
<table width="99%" height="90%" border="0" cellspacing="1" cellpadding="3" align="center" class="verd">
<tr bgcolor="#C0C0C0">
<td colspan="7"><div align="center">
<a href="?goDate=<%=DateAdd("m",-1,goDate)%>" title='previous month'><<</a>
<% =MonthName(goDateMonth) %> - <% =goDateYear %>
<a href="?goDate=<%=DateAdd("m",1,goDate)%>" title='next month'>>></a></div></td>
</tr>
<tr bgcolor="#000000">
<td align="center" class="style1" width="14%">S</td>
<td align="center" class="style1" width="14%">M</td>
<td align="center" class="style1" width="14%">T</td>
<td align="center" class="style1" width="14%">W</td>
<td align="center" class="style1" width="14%">T</td>
<td align="center" class="style1" width="14%">F</td>
<td align="center" class="style1" width="14%">S</td>
</tr>
<tr>
<%weekdayCell=1%>
<%'+++ empty days +++%>
<%i=1%>
<%do while i<goDateFirstWeekday %>
<td><% if weekdayCell=1 then %> <img src="" width="1" height="80" align="texttop" />
<%end if%></td>
<%i=i+1%>
<%weekdayCell=weekdayCell+1%>
<%loop%>
<%'++++++++++++++++++%>
<%'+++ month days +++%>
<%wday=0%>
<%cellDate=goDateFirst%>
<%do while wday<goDateTotalDays %>
<td valign="top" bgcolor="#F9F9F9" class="printstyle" style="vertical-align: top;">
<a href="?goDate=<%=cellDate%>" style='text-decoration: none; color: red;' title="<%=cellDate%>"><%=day(cellDate)%></a>
<% if weekdayCell=1 then %><img src="" width="1" height="80" align="texttop" /><%end if%>
<%
if recordcount > 0 then
count = 0
For I = iRecFirst To iRecLast
id = data(0,I)
eventdate = data(1,I)
eventtime = data(2,I)
eventname = data(3,I)
eventdesc = data(4,I)
if celldate = eventdate then
'display a divider if there is more than 1 record per day.
count = count + 1
if count > 1 then
response.write "<hr style='height: 1px; color: gray' width='50%'>"
end if
response.write "<small class='verd'>" & eventtime & "-" & eventname & "</small>"
end if
Next
end if
%>
</td>
<% if weekdayCell=7 then %>
</tr>
<tr>
<%
weekdayCell=1
else
weekdayCell=weekdayCell+1
end if
%>
<% cellDate=DateAdd("d",1,cellDate)
%>
<%wday=wday+1%>
<%loop%>
</tr>
</table>
<% if print <> 1 then %>
<p class="verd"><a href="?godate=<%=godate%>&print=1">Print Format</a></p>
<% end if %>
<!-- #include virtual="include/footer.asp" -->
</body>
</html>