I have a calendar that takes information from a table in access
now, the following code-displays the info-but when you click on an event-it just displays the last event
so if I have more than one record for a day-I see all on the calendar-but when I click on any of them-I get directed to the page -with the information for the last record (instead of each line-linking me to that record's information)
each record has an ID-so I'd like to go through that.
any ideas of how I should proceed
here's the code: (I'll give you the whole file-just in case you want to look at other info)
thank you
<%@ LANGUAGE="VBScript" %>
<%
'Option Explicit
dim calendarname,rsinfo,getinfo,daconn,fn_now
if request.querystring("calendar"
<> "" then
calendarname=request.querystring("calendar"
response.cookies("calendar"
=request.querystring("calendar"
else
calendarname=request.cookies("calendar"
end if
'response.write request.cookies("calendar"
Session("submitted"
= True
%>
<!-- #include file="db.asp" -->
<%
set my_conn= daconn
Function FormatStr(String)
on Error resume next
String = Replace(String, CHR(13), ""
String = Replace(String, CHR(10) & CHR(10), "</P><P>"
String = Replace(String, CHR(10), "<BR>"
FormatStr = String
End Function
Dim dtToday,my_conn,dbpath,payroll,strsql,rs,rs2,rs3,strsql2,stryear,rsyearly,cnpath
dtToday = Date()
Dim dtCurViewMonth ' First day of the currently viewed month
Dim dtCurViewDay ' Current day of the currently viewed month
Dim frmDate,tmpMonth,tmpYear,tmpDate,mnth ' Date submitted by form
' if the GO button was used, build the date from the month and year
If InStr(1, Request.Form, "subGO", 1) > 0 then
if Request.Form("CURDATE_month"
= "" then
tmpMonth = month(now())
else
tmpMonth = Request.Form("CURDATE_month"
End If
if Request.Form("CURDATE_year"
= "" then
tmpyear = year(now())
else
tmpyear = Request.Form("CURDATE_year"
End If
tmpDate = "1 " & tmpMonth & " 2001"
mnth = Month(tmpDate)
frmDate = DateSerial(tmpyear, mnth, 1)
Else
frmDate = Request.Form("CURDATE"
end if
if Request("view_date"
<> "" then
frmDate= DateSerial(year(Request("view_date"
), month(Request("view_date"
), 1)
end if
%>
<% REM This section defines functions to be used later on. %>
<% REM This sets the Previous Sunday and the Current Month %>
<%
'--------------------------------------------------
Function DtPrevSunday(ByVal dt)
Do While WeekDay(dt) > vbSunday
dt = DateAdd("d", -1, dt)
Loop
DtPrevSunday = dt
End Function
'--------------------------------------------------
%>
<%REM Set current view month from posted CURDATE, or
' the current date as appropriate.
' if posted from the form
' if prev button was hit on the form
If InStr(1, Request.Form, "subPrev", 1) > 0 Then
dtCurViewMonth = DateAdd("m", -1, frmDate)
' if next button was hit on the form
ElseIf InStr(1, Request.Form, "subNext", 1) > 0 Then
dtCurViewMonth = DateAdd("m", 1, frmDate)
' elseif request.querystring("subprev"
=1 then
' dtCurViewMonth = DateAdd("m", -1, frmDate)
' anyother time
Else
' date add in text box
If InStr(1, Request.Form, "subGO", 1) > 0 then
dtCurViewMonth = frmDate
Else
if Request("view_date"
<> "" then
dtCurviewMonth = frmDate
else
dtCurViewMonth = DateSerial(Year(dtToday), Month(dtToday), 1)
End If
End If
End If
%>
<% REM --------BEGINNING OF DRAW CALENDAR SECTION-------- %>
<% REM This section executes the event query and draws a matching calendar. %>
<%
Dim iDay, iWeek, sFontColor, dictDte(31,2), intCount
'get calendar info
'getinfo="select * from main where tablename='" &calendarname &"';"
'set rsinfo=my_conn.execute(getinfo)
strSql = "SELECT * FROM evantcalendar WHERE year(dte) = " & year(dtCurViewMonth) &" AND month(dte)= " & month(dtCurViewMonth) & " ORDER BY Day(dte)"
'response.write strsql &"<BR>"
set rs = my_conn.Execute (StrSql)
intCount= 0
' populate array with days of month
do until rs.EOF or intCount = 31
dictDte(intCount, 2) = intCount + 1
if Day(rs("dte"
) = intCount + 1 then
if dictDte(intCount, 1) <> "" then
dictDte(intCount, 1) = rs("text_field"
& "<br>" & dictDte(intCount, 1)
else
dictDte(intCount, 1) = rs("text_field"
end if
rs.Movenext
else
intCount = intCount + 1
End If
loop
rs.close
dim contactrs,consql
dim priconrs,prisql
'consql="select * from contacts where email<>'" &rsinfo("primary_contact"
&"' AND email in (select contact from calcontact where visible=yes AND calendar='" &rsinfo("title"
&"');"
'response.write con1sql
'set contactrs=my_conn.execute(consql)
'prisql="select * from contacts where email='" &rsinfo("primary_contact"
&"';"
'response.write prisql
'set priconrs=my_conn.execute(prisql)
%>
<html>
<head>
<!--#INCLUDE FILE="../header.asp" -->
<title> - Web Calendar</title>
<style fprolloverstyle>A:hover {color: #00FF00; text-decoration: none}
</style>
</head>
<body text="#000000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<table border=0 width="100%">
<tr>
<td width="99%"><h1 align="center"><font color="#003399" size="4">Yeled
V'Yalda Event Calendar</font></h1>
</td>
</tr>
</table>
<table CELLPADDING="3" CELLSPACING="0" WIDTH="100%" BORDER="2" BGCOLOR="#000099" bordercolordark="#1C644C" bordercolor="#000099" bordercolorlight="#FFFFFF">
<tr VALIGN="MIDDLE" ALIGN="CENTER">
<form NAME="fmNextPrev" ACTION="index.asp" METHOD="POST"><input type="hidden" name="CURDATE" value="<%=dtCurViewMonth%>">
<td WIDTH="30%" ALIGN="RIGHT">
<input TYPE="image" NAME="subPrev" SRC="previousmonth.gif" BORDER="0" align="right"></span>
</td>
<td WIDTH="40%"><font FACE="Arial" COLOR="white"><b><%=MonthName(Month(dtCurViewMonth)) & " " & Year(dtCurViewMonth)%>
</td>
<td WIDTH="30%" ALIGN="LEFT" colspan="7"> <input TYPE="image" NAME="subNext" SRC="nextmonth.gif" BORDER="0" HSPACE="0" VSPACE="0" align="absbottom">
</td>
</form>
</tr>
</table>
<table CELLPADDING="3" CELLSPACING="0" WIDTH="100%" BORDER="2" BGCOLOR="#0000FF" bordercolordark="#008000" bordercolor="#000099" bordercolorlight="#FFFFFF" style="border-collapse: collapse">
<tr VALIGN="TOP" ALIGN="CENTER" BGCOLOR="#000099">
<% For iDay = vbSunday To vbSaturday %>
<th WIDTH="14%"><font FACE="Arial" SIZE="-2" COLOR="#FFFFFF"><%=WeekDayName(iDay)%></font> </th>
<%Next %>
</tr>
<%
dtCurViewDay = DtPrevSunday(dtCurViewMonth)
For iWeek = 0 To 5
Response.Write "<TR VALIGN=TOP>" & vbCrLf
Dim sBGCOLOR
sBGCOLOR = "#99ccff"
For iDay = 0 To 6
sBGCOLOR = "#003399"
If Month(dtCurViewDay) = Month(dtCurViewMonth) Then
If dtCurViewDay = dtToday Then sBGCOLOR = "#99ccff"
else
sBGCOLOR = "#003399"
End If
Response.Write "<span><a href=view_day.asp?" & "view_date=" & day(dtCurViewday) & "-" & monthname(month(dtCurViewday)) & "-"&Year(dtCurViewMonth)&"><TD HEIGHT=50 bgcolor='" & sBGCOLOR & "' style=""cursor:hand"" >"
If Month(dtCurViewDay) = Month(dtCurViewMonth) Then
If dtCurViewDay = dtToday Then
sFontColor = "#00FF00<i></i>"
Else
sFontColor = "#00FF00"
End If
'---- Write day of month
Response.Write "<FONT FACE=""Arial"" SIZE=""-2"" COLOR=""" & sFontColor & """><B>"
Response.Write "<a name=" &Day(dtCurViewDay) & "><a href=view_day.asp?" & "view_date=" & day(dtCurViewday) & "-" & monthname(month(dtCurViewday)) & "-"&Year(dtCurViewMonth)&">" & Day(dtCurViewDay) & "</B><br><font color='" &sFontColor &"'>" & formatStr(dictDte(Day(dtCurViewDay)- 1, 1)) & "</a>"
End If
Response.Write " </TD></a></span>" & vbCrLf
dtCurViewDay = DateAdd("d", 1, dtCurViewDay)
Next
Response.Write "</TR>" & vbCrLf
Next
%>
<%REM --------END OF DRAW CALENDAR SECTION--------
my_conn.Close
set my_conn = nothing
%></table>
<table width="100%"><tr><td width="33%"> </td><td width="33%">
<center> <p align="center"><form NAME="fmNextPrev2" ACTION="index.asp" METHOD="POST">
<select name="CURDATE_month" size="1">
<option value="<%=monthName(month(dtCurViewMonth))%>" selected><%=monthName(month(dtCurViewMonth))%> </option>
<option value="January">January </option>
<option value="February">February </option>
<option value="March">March </option>
<option value="April">April </option>
<option value="May">May </option>
<option value="June">June </option>
<option value="July">July </option>
<option value="August">August </option>
<option value="September">September </option>
<option value="October">October </option>
<option value="November">November </option>
<option value="December">December </option>
</select> <input TYPE="text" NAME="CURDATE_YEAR" VALUE="<%=year(dtCurViewMonth)%>" size="6">
<input type="submit" value="Click Me" name="subGO"></form> </p></td><td width="33%" valign="top">
<p align="right">
<font color=black>Yearly events are in </font><span style="background-color: #000099"><font color="#FFFF00">
yellow </font></span></p>
</td></tr>
</table>
</body>
now, the following code-displays the info-but when you click on an event-it just displays the last event
so if I have more than one record for a day-I see all on the calendar-but when I click on any of them-I get directed to the page -with the information for the last record (instead of each line-linking me to that record's information)
each record has an ID-so I'd like to go through that.
any ideas of how I should proceed
here's the code: (I'll give you the whole file-just in case you want to look at other info)
thank you
<%@ LANGUAGE="VBScript" %>
<%
'Option Explicit
dim calendarname,rsinfo,getinfo,daconn,fn_now
if request.querystring("calendar"
calendarname=request.querystring("calendar"
response.cookies("calendar"
else
calendarname=request.cookies("calendar"
end if
'response.write request.cookies("calendar"
Session("submitted"
%>
<!-- #include file="db.asp" -->
<%
set my_conn= daconn
Function FormatStr(String)
on Error resume next
String = Replace(String, CHR(13), ""
String = Replace(String, CHR(10) & CHR(10), "</P><P>"
String = Replace(String, CHR(10), "<BR>"
FormatStr = String
End Function
Dim dtToday,my_conn,dbpath,payroll,strsql,rs,rs2,rs3,strsql2,stryear,rsyearly,cnpath
dtToday = Date()
Dim dtCurViewMonth ' First day of the currently viewed month
Dim dtCurViewDay ' Current day of the currently viewed month
Dim frmDate,tmpMonth,tmpYear,tmpDate,mnth ' Date submitted by form
' if the GO button was used, build the date from the month and year
If InStr(1, Request.Form, "subGO", 1) > 0 then
if Request.Form("CURDATE_month"
tmpMonth = month(now())
else
tmpMonth = Request.Form("CURDATE_month"
End If
if Request.Form("CURDATE_year"
tmpyear = year(now())
else
tmpyear = Request.Form("CURDATE_year"
End If
tmpDate = "1 " & tmpMonth & " 2001"
mnth = Month(tmpDate)
frmDate = DateSerial(tmpyear, mnth, 1)
Else
frmDate = Request.Form("CURDATE"
end if
if Request("view_date"
frmDate= DateSerial(year(Request("view_date"
end if
%>
<% REM This section defines functions to be used later on. %>
<% REM This sets the Previous Sunday and the Current Month %>
<%
'--------------------------------------------------
Function DtPrevSunday(ByVal dt)
Do While WeekDay(dt) > vbSunday
dt = DateAdd("d", -1, dt)
Loop
DtPrevSunday = dt
End Function
'--------------------------------------------------
%>
<%REM Set current view month from posted CURDATE, or
' the current date as appropriate.
' if posted from the form
' if prev button was hit on the form
If InStr(1, Request.Form, "subPrev", 1) > 0 Then
dtCurViewMonth = DateAdd("m", -1, frmDate)
' if next button was hit on the form
ElseIf InStr(1, Request.Form, "subNext", 1) > 0 Then
dtCurViewMonth = DateAdd("m", 1, frmDate)
' elseif request.querystring("subprev"
' dtCurViewMonth = DateAdd("m", -1, frmDate)
' anyother time
Else
' date add in text box
If InStr(1, Request.Form, "subGO", 1) > 0 then
dtCurViewMonth = frmDate
Else
if Request("view_date"
dtCurviewMonth = frmDate
else
dtCurViewMonth = DateSerial(Year(dtToday), Month(dtToday), 1)
End If
End If
End If
%>
<% REM --------BEGINNING OF DRAW CALENDAR SECTION-------- %>
<% REM This section executes the event query and draws a matching calendar. %>
<%
Dim iDay, iWeek, sFontColor, dictDte(31,2), intCount
'get calendar info
'getinfo="select * from main where tablename='" &calendarname &"';"
'set rsinfo=my_conn.execute(getinfo)
strSql = "SELECT * FROM evantcalendar WHERE year(dte) = " & year(dtCurViewMonth) &" AND month(dte)= " & month(dtCurViewMonth) & " ORDER BY Day(dte)"
'response.write strsql &"<BR>"
set rs = my_conn.Execute (StrSql)
intCount= 0
' populate array with days of month
do until rs.EOF or intCount = 31
dictDte(intCount, 2) = intCount + 1
if Day(rs("dte"
if dictDte(intCount, 1) <> "" then
dictDte(intCount, 1) = rs("text_field"
else
dictDte(intCount, 1) = rs("text_field"
end if
rs.Movenext
else
intCount = intCount + 1
End If
loop
rs.close
dim contactrs,consql
dim priconrs,prisql
'consql="select * from contacts where email<>'" &rsinfo("primary_contact"
'response.write con1sql
'set contactrs=my_conn.execute(consql)
'prisql="select * from contacts where email='" &rsinfo("primary_contact"
'response.write prisql
'set priconrs=my_conn.execute(prisql)
%>
<html>
<head>
<!--#INCLUDE FILE="../header.asp" -->
<title> - Web Calendar</title>
<style fprolloverstyle>A:hover {color: #00FF00; text-decoration: none}
</style>
</head>
<body text="#000000" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<table border=0 width="100%">
<tr>
<td width="99%"><h1 align="center"><font color="#003399" size="4">Yeled
V'Yalda Event Calendar</font></h1>
</td>
</tr>
</table>
<table CELLPADDING="3" CELLSPACING="0" WIDTH="100%" BORDER="2" BGCOLOR="#000099" bordercolordark="#1C644C" bordercolor="#000099" bordercolorlight="#FFFFFF">
<tr VALIGN="MIDDLE" ALIGN="CENTER">
<form NAME="fmNextPrev" ACTION="index.asp" METHOD="POST"><input type="hidden" name="CURDATE" value="<%=dtCurViewMonth%>">
<td WIDTH="30%" ALIGN="RIGHT">
<input TYPE="image" NAME="subPrev" SRC="previousmonth.gif" BORDER="0" align="right"></span>
</td>
<td WIDTH="40%"><font FACE="Arial" COLOR="white"><b><%=MonthName(Month(dtCurViewMonth)) & " " & Year(dtCurViewMonth)%>
</td>
<td WIDTH="30%" ALIGN="LEFT" colspan="7"> <input TYPE="image" NAME="subNext" SRC="nextmonth.gif" BORDER="0" HSPACE="0" VSPACE="0" align="absbottom">
</td>
</form>
</tr>
</table>
<table CELLPADDING="3" CELLSPACING="0" WIDTH="100%" BORDER="2" BGCOLOR="#0000FF" bordercolordark="#008000" bordercolor="#000099" bordercolorlight="#FFFFFF" style="border-collapse: collapse">
<tr VALIGN="TOP" ALIGN="CENTER" BGCOLOR="#000099">
<% For iDay = vbSunday To vbSaturday %>
<th WIDTH="14%"><font FACE="Arial" SIZE="-2" COLOR="#FFFFFF"><%=WeekDayName(iDay)%></font> </th>
<%Next %>
</tr>
<%
dtCurViewDay = DtPrevSunday(dtCurViewMonth)
For iWeek = 0 To 5
Response.Write "<TR VALIGN=TOP>" & vbCrLf
Dim sBGCOLOR
sBGCOLOR = "#99ccff"
For iDay = 0 To 6
sBGCOLOR = "#003399"
If Month(dtCurViewDay) = Month(dtCurViewMonth) Then
If dtCurViewDay = dtToday Then sBGCOLOR = "#99ccff"
else
sBGCOLOR = "#003399"
End If
Response.Write "<span><a href=view_day.asp?" & "view_date=" & day(dtCurViewday) & "-" & monthname(month(dtCurViewday)) & "-"&Year(dtCurViewMonth)&"><TD HEIGHT=50 bgcolor='" & sBGCOLOR & "' style=""cursor:hand"" >"
If Month(dtCurViewDay) = Month(dtCurViewMonth) Then
If dtCurViewDay = dtToday Then
sFontColor = "#00FF00<i></i>"
Else
sFontColor = "#00FF00"
End If
'---- Write day of month
Response.Write "<FONT FACE=""Arial"" SIZE=""-2"" COLOR=""" & sFontColor & """><B>"
Response.Write "<a name=" &Day(dtCurViewDay) & "><a href=view_day.asp?" & "view_date=" & day(dtCurViewday) & "-" & monthname(month(dtCurViewday)) & "-"&Year(dtCurViewMonth)&">" & Day(dtCurViewDay) & "</B><br><font color='" &sFontColor &"'>" & formatStr(dictDte(Day(dtCurViewDay)- 1, 1)) & "</a>"
End If
Response.Write " </TD></a></span>" & vbCrLf
dtCurViewDay = DateAdd("d", 1, dtCurViewDay)
Next
Response.Write "</TR>" & vbCrLf
Next
%>
<%REM --------END OF DRAW CALENDAR SECTION--------
my_conn.Close
set my_conn = nothing
%></table>
<table width="100%"><tr><td width="33%"> </td><td width="33%">
<center> <p align="center"><form NAME="fmNextPrev2" ACTION="index.asp" METHOD="POST">
<select name="CURDATE_month" size="1">
<option value="<%=monthName(month(dtCurViewMonth))%>" selected><%=monthName(month(dtCurViewMonth))%> </option>
<option value="January">January </option>
<option value="February">February </option>
<option value="March">March </option>
<option value="April">April </option>
<option value="May">May </option>
<option value="June">June </option>
<option value="July">July </option>
<option value="August">August </option>
<option value="September">September </option>
<option value="October">October </option>
<option value="November">November </option>
<option value="December">December </option>
</select> <input TYPE="text" NAME="CURDATE_YEAR" VALUE="<%=year(dtCurViewMonth)%>" size="6">
<input type="submit" value="Click Me" name="subGO"></form> </p></td><td width="33%" valign="top">
<p align="right">
<font color=black>Yearly events are in </font><span style="background-color: #000099"><font color="#FFFF00">
yellow </font></span></p>
</td></tr>
</table>
</body>