hi - need help with listing results in a date planner.
have the following code that i wish to display results like this-
Jan
---------------------------------------------
Holiday
Jim 01/01/2007 05/01/2007
Training
Fred 01/01/2007 04/01/2007
Bill 04/01/2007 08/01/2007
DaysOff
Linda 08/01/2007 11/01/2007
Feb
---------------------------------------------
Holiday
Fred 02/02/2007 14/02/2007
Training
Bill 09/02/2007 16/02/2007
DaysOff
Sue 01/02/2007 14/02/2007
etc,etc...
my code lists the months and gets the people with holidays/ training/days off under the month headings.
but then i put another loop in to add the holiday/training/daysoff headings under each month
which is fine but i cant get the right type of holidaytype
underneath the holtype heading.
i have used two recordsets for this, one for the people
and another to list the holiday types - am sure someone can think of a better way!!
and ideas welcome - have tried for ages
have the following code that i wish to display results like this-
Jan
---------------------------------------------
Holiday
Jim 01/01/2007 05/01/2007
Training
Fred 01/01/2007 04/01/2007
Bill 04/01/2007 08/01/2007
DaysOff
Linda 08/01/2007 11/01/2007
Feb
---------------------------------------------
Holiday
Fred 02/02/2007 14/02/2007
Training
Bill 09/02/2007 16/02/2007
DaysOff
Sue 01/02/2007 14/02/2007
etc,etc...
my code lists the months and gets the people with holidays/ training/days off under the month headings.
but then i put another loop in to add the holiday/training/daysoff headings under each month
which is fine but i cant get the right type of holidaytype
underneath the holtype heading.
i have used two recordsets for this, one for the people
and another to list the holiday types - am sure someone can think of a better way!!
and ideas welcome - have tried for ages
Code:
<%'sql/rs for people
dstartdatesql = "2007/01/01"
denddatesql = "2007/12/31"
sqlside= "SELECT CC.username, CB.bookst, CB.bookend, CC.userid, CB.holbookid, CB.holtypeid, holtype.holtypeimg "
sqlside= sqlside & "FROM holbook AS CB "
sqlside= sqlside & "LEFT JOIN user AS CC ON CC.userid = CB.userholid "
sqlside= sqlside & "LEFT JOIN holtype ON holtype.holtypeid = CB.holtypeid "
sqlside= sqlside & " WHERE (cb.bookst BETWEEN '"&dstartdatesql&"' AND '"&denddatesql&"') "
sqlside= sqlside & "ORDER BY CB.bookst, CB.holtypeid"
Set RSside = Conn.Execute(sqlside)
'sql/rs for holtypes
sqlholtype = "SELECT holtypeid, holtype, holtypeimg FROM holtype ORDER BY holtypeid"
Set RSholtype = Conn.Execute(sqlholtype)
dStartDate = "01/01/2007"
dEndDate = "31/12/2007"
Response.Write("<table border=0 cellpadding=2 cellspacing=1 width=620>")
Response.Write("<tr>")
Response.Write("<td colspan =2 class = usersml><img src=""images/bookbuthol.gif""><span class = usersml>Holiday</span><img src=""images/bookbuttrain.gif""><span class = usersml>Train</span><img src=""images/bookbutoff.gif""><span class = usersml>Day Off</span></td>")
Response.Write("<td colspan=3></td>")
Response.Write("</tr>")
for i=0 to DateDiff("m",dStartDate,dEndDate)
daydate = (dateadd("m",i,dStartDate))
daynumshort = Month(daydate)
dayshort = formatDate ("%M",(daydate))
recCount = recCount + 1
bgcolor = "#ffffff"
Response.Write "<tr bgcolor = #333333><td class = usersml colspan=2>" & dayshort & "</td><td class = mfitsmlwhite>Start</td><td class = mfitsmlwhite>End</td><td class = mfitsmlwhite>Days</td></tr>"
rsholtype.movefirst
Do While not rsholtype.eof
x_holtypeid2 = rsholtype("holtypeid")
x_holtype2 = rsholtype("holtype")
x_holtypeimg2 = rsholtype("holtypeimg")
Response.Write "<tr><td><img src=images/" & (x_holtypeimg2) &" border=0 align=center></td><td class = usersml colspan=3>" & x_holtype2 & "</td></tr>"
Do while not rsside.eof
holtypeid = rsside("holtypeid")
bookst = rsside("bookst")
bookstmonth = month(bookst)
if bookstmonth <> daynumshort then exit do
if x_holtypeid2 <> holtypeid then exit do
employee = rsside("username")
bookend = rsside("bookend")
holbookid = rsside("holbookid")
holtypeimg = rsside("holtypeimg")
bookdiff = DateDiff("d",bookst,bookend)
bookdiff = bookdiff + 1
Response.Write("<tr>")
response.write "<td><img src=images/" & (holtypeimg) &" border=0 align=center></td><td class=mfitsml><a href='addhol.asp?holbookid=" & (holbookid) & "&deptid=" & (deptid) & "'target=""_blank"" onClick=""window.open(this.href, this.target, 'height=300,width=480,status=no,resizable=no,scrollbars=no');return false;""><span class=courtcarreg>"& employee &"</span></a></td><td class=mfitsml>"& bookst & "</td><td class=mfitsml>" & bookend &"</td><td class=mfitsml>" & bookdiff & "</td>"
response.write "</tr>"
'end if
rsside.movenext
loop
rsholtype.movenext
loop
next
Response.Write("</table>") %>