Avatar billede andersasp Nybegynder
28. oktober 2004 - 14:42 Der er 1 løsning

Loop af records i kalender!

Hejsa eksperter!

Jeg har et kalender script som virker helt godt! jeg vil dog nu gerne vise noget mere data i nu, hvor 2 stk. events godt kan forekomme på samme dato! 

Derfor vil jeg gerne have noget loop, således at events bliver vist under hinanden!!  Håber dette kan lade sig gøre??

På nuværende tidspunkt udskriver den blot den første hvis der er flere på en dato..  den udskriver her:

      ' Checks for a message on the day being written
      strSQL = "SELECT * FROM tourplan WHERE Tdato = #" & dtOnDay & "#"
      Set objRS = objConn.Execute(strSQL)
      If NOT objRS.EOF Then
        dailyMsg = objRS("Tsted") & " kl:" & objRS("Ttid")
      Else
        dailyMsg = ""
      End If
      Set objRS = Nothing

Hele koden kan ses her:

<%
    Function FormatStr(String)
      ' Replaces a double carrige return with a paragraph break
      ' a single carrige return with a break rule and CHR(13) with nothing
      String = Replace(String, CHR(13), "")
      String = Replace(String, CHR(10) & CHR(10), "</P><P>")
      String = Replace(String, CHR(10), "<BR>")
      FormatStr = String
    End Function

' ---------- Page Variables ----------
    Const intCharToShow = 19        ' The number of characters shown in each day
    Const bolEditable  = True        ' If the calendar is editable or not (Can be tied into password verification)

    Dim dtToday             ' Today's Date
    Dim dtCurrentDate            ' The current date
    Dim aCalendarDays(42)        ' Array of possible calendar dates
    Dim iFirstDayOfMonth        ' The first day of the month
    Dim iDaysInMonth            ' The number of days in the month
    Dim iColumns, iRows    , iDay, iWeek    ' The numer of columns and rows in the table, and counters to print them
    Dim objConn, strConn, strSQL, objRS ' Database Variables
    Dim counter             ' Loop counter
    Dim strNextMonth, strPrevMonth    ' The next and previous month dates
    Dim dailyMsg            ' The message for the day
    Dim dtOnDay                ' The current day being displayed by the loops
    Dim strPage                ' The link that each day takes you too

' ---------- Variable Definitions ----------
    dtToday       = Date()

    If Request("currentDate") <> "" Then
      dtCurrentDate = Request("currentDate")
    Else
      dtCurrentDate = dtToday
    End If

    iFirstDayOfMonth = DatePart("w", DateSerial(Year(dtCurrentDate), Month(dtCurrentDate), 1))
    iDaysInMonth = DatePart("d", DateSerial(Year(dtCurrentDate), Month(dtCurrentDate)+1, 1-1))

    For counter = 1 to iDaysInMonth
      aCalendarDays(counter + iFirstDayOfMonth - 1) = counter
    Next

    iColumns = 7
    iRows    = 6 - Int((42 - (iFirstDayOfMonth + iDaysInMonth)) / 7)

    strPrevMonth = Server.URLEncode(DateAdd("m", -1, dtCurrentDate))
    strNextMonth = Server.URLEncode(DateAdd("m",  1, dtCurrentDate))

' ---------- Drawing the Calendar ----------
%>

<HTML>
<HEAD>
  <TITLE>Caledar - <%= MonthName(Month(dtCurrentDate)) & " " & Year(dtCurrentDate) %></TITLE>
  <STYLE TYPE="text/css">
    <!--
    BODY         {background-color: #FFFFFF; text-align: center; font-size: 12px; font-family: Verdana;}
    A             {text-decoration: none;}
    A:active         {color: #000000;}
    A:visited         {color: #000000;}
    A:link         {color: #000000;}
    A:hover         {color: #D80E0E;}
    .blackBacking  {background-color: #000000;}
    .names         {background-color: #4C5D87; font-size: 13px; color: #FFFFFF; text-decoration: none; text-align:  center; font-family: Verdana; font-weight: bold;}
    .calendarBody  {background-color: #F0F0F0; font-size: 12px; color: #000000; text-decoration: none; text-align:  center; font-family: Verdana;}
    .calCurrentDay  {background-color: #C0C0C0; font-size: 9px; color: #FFFFFF;}
    .calOtherDay    {background-color: #F0F0F0; font-size: 9px; color: #000000;}
    .calNotDay        {background-color: #F0F0F0; font-size: 9px; color: #000000;}
    .calFormMenu    {background-color: #4C5D87; font-size: 13px; color: #FFFFFF; text-decoration: none; text-align:  center; font-family: Verdana; font-weight: bold;}
.style1 {color: #FFFFFF}
.style2 {font-size: 13px; text-decoration: none; text-align: center; font-family: Verdana; font-weight: bold; background-color: #4C5D87;}
    -->
  </STYLE>
</HEAD>
<BODY>
<FORM NAME="pageForm" ACTION="calendar.asp" METHOD="GET">
  <CENTER>
    <TABLE CELLPADDING=0 CELLSPACING=0 WIDTH=600 BORDER=0>
      <TR>
        <TD CLASS="blackBacking">
          <TABLE CELLSPACING=1 CELLPADDING=1 BORDER=0 WIDTH=600>
            <TR HEIGHT=30px>
              <TD HEIGHT=30px COLSPAN=7 CLASS="names style1"> <A HREF="calendar.asp?currentDate=<%= strPrevMonth %>">&laquo; Prev</A> &nbsp;
                  <SELECT NAME="currentDate" CLASS="style2" onChange="pageForm.submit()">
                    <% For counter = 1 to 12 %>
                    <OPTION VALUE="<%= DateSerial(Year(dtCurrentDate), counter, 1) %>" <% If (DatePart("m", dtCurrentDate) = counter) Then Response.Write "SELECTED"%>><%= MonthName(counter) & " " & Year(dtCurrentDate) %></OPTION>
                    <% Next %>
                  </SELECT>
&nbsp; <A HREF="calendar.asp?currentDate=<%= strNextMonth %>">Next &raquo;</A> </TD>
            </TR>
            <!-- Writring the days of the week for headers -->
            <TR VALIGN="TOP" ALIGN="CENTER">
              <% For iDay = vbSunday To vbSaturday %>
              <TD WIDTH="14%" class="names"><%= WeekDayName(iDay, True) %></TD>
              <% Next %>
            </TR>
            <%

Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open MM_artmusic_STRING

    For iWeek = 1 To iRows
      Response.Write "<TR VALIGN=TOP>"
      For iDay = 1 To iColumns
    ' Checks to see if there is a day this month on the date being written
    If aCalendarDays((iWeek-1)*7 + iDay) > 0 then
      dtOnDay = DateSerial(Year(dtCurrentDate), Month(dtCurrentDate), aCalendarDays((iWeek-1)*7 + iDay))

      ' Checks to see if the day being printed is today
      If dtOnDay = dtToday Then
        Response.Write "<TD HEIGHT=55 CLASS='calCurrentDay'>"
      Else
          Response.Write "<TD HEIGHT=55 CLASS='calOtherDay'>"
      End If

      ' Checks to see the type of calendar (editable or non-editable)
      If (bolEditable) then
          strPage = "updateCalendar_form.asp?currentDate=" & dtOnDay
      Else
          strPage = "viewDay.asp?currentDate=" & dtOnDay
      End If

      ' Checks for a message on the day being written
      strSQL = "SELECT * FROM tourplan WHERE Tdato = #" & dtOnDay & "#"
      Set objRS = objConn.Execute(strSQL)
      If NOT objRS.EOF Then
        dailyMsg = objRS("Tsted") & " kl:" & objRS("Ttid")
      Else
        dailyMsg = ""
      End If
      Set objRS = Nothing

      ' Checks to see if the message is too long to be displayed in the mini date box
          If (Trim(dailyMsg) = Trim(Left(dailyMsg, intCharToShow))) Then
      Else
        dailyMsg = Trim(Left(dailyMsg, intCharToShow-4)) & " ..."
          End If

      Response.Write ("<A HREF=""" & strPage & """>&nbsp;" & aCalendarDays((iWeek-1)*7 + iDay) & "<BR>&nbsp;&nbsp;" & FormatStr(dailyMsg) & "</A>")
    Else
      Response.Write ("<TD HEIGHT=50 CLASS='calNotDay'>&nbsp;")
    End IF

    Response.Write "</TD>"
      Next
      Response.Write "</TR>"
    Next

    objConn.Close
    set objConn = Nothing
%>
Avatar billede andersasp Nybegynder
03. november 2004 - 12:58 #1
jeg prøver lige at omformulere mig i et andet spørgsmål!
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester