Risikio wrote:
> Not sure if I am in the right forum/area. I am looking for some help with
> writing an .asp code. I was given an .asp code for an editable calendar, that
> I think was downloaded from one of those free code websites. I am new to .asp
> code, so I am asking for help. The code allows only one event per date to be
> added to the calendar, and I need to make the code work for up to three
> events per date. I have tried looping the code, but can not get it to read
> the second event for a particular date from the MS Access database table. Any
> help would be greatly appreciated. I have already spent more time on this
> than I can afford to. Here is the code. Thanks.
>
>
> <!--#include file = "database.inc" -->
> <%
> i = 0
> iLastDay = LastDay(iYear, iMonth)
> iFirstDay= Weekday(CDate(imonth & "/01/" & iYear))
> iLastDay = iFirstDay + iLastDay - 1
>
> do while i<= iLastDay
> if i <> iLastDay then
> Response.Write ("<tr>")
> else
> exit do
> end if
> for j=1 to 7
>
> if (j < iFirstDay and i = 0) or (i + j > iLastDay) then
>
> Response.Write ("<td width='90' height='75' valign='top' bgcolor='#000080'
> NOWRAP></td>")
> else
> k = k + 1
> sDate = "#" & iMonth & "/" & k & "/" & iYear & "#"
> set rs = conn.execute("SELECT * FROM EVENTS WHERE DATE = " & sDate)
> if rs.eof then
> sHREF = "AddEvent.asp"
> sEvent = ""
> else
> sHREF = "EditEvent.asp"
> sEvent = " <P><FONT SIZE=-2 FACE='Arial,Helvetica'><A HREF =
> 'javascript:showevent(" & rs("ID") & ")'>" & rs("Description") & "</A><BR>"
> if FixNull(rs("Time")) <> "" then sEvent = sEvent & rs("Time") & "<BR>"
> if FixNull(rs("Location")) <> "" then sEvent = sEvent & rs("Location")
> sEvent = sEvent & "</FONT>"
> End If
> sHREF = sHREF & "?Month=" & iMonth & "&Day=" & k & "&Year=" & iYear
> Response.Write ("<td width='90' height='75' valign='top'>")
> Response.Write "<B>"
> Response.write k & "</A></B>" & sEvent
> Response.Write ("</td>")
> end if
>
> next
> i=i+7
>
> loop
> Response.Write ("</tr>")
> %>
> <!--#include file = "database_cleanup.inc"-->
You have to use the movenext method to write out more than one record
(if there is more than one record in the recordset in the first place)
.....amended code....
else
sEvent = ""
do until rs.eof
sHREF = "EditEvent.asp"
sEvent = sEvent & " <P><FONT SIZE=-2 FACE='Arial,Helvetica'><A
HREF =
'javascript:showevent(" & rs("ID") & ")'>" & rs("Description") &
"</A><BR>"
if FixNull(rs("Time")) <> "" then sEvent = sEvent & rs("Time") & "<BR>"
if FixNull(rs("Location")) <> "" then sEvent = sEvent & rs("Location")
sEvent = sEvent & "</FONT>"
rs.movenext
loop
End If
/P.
|