Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1091
  • Last Modified:

calendar application - more than one event at at time in table (date) cell

the link to my calendar app:

http://www.redcatweb2.org/calendar/index.cfm

i need to be able to show more than one event in a table cell. currently if i add an event to a date already being used by another event, the new event takes over the spot of the old event and the old event isn't displayed anymore.

my code:

<cfquery name="craigcal" datasource="calartscalendar">
SELECT * FROM calendar
</cfquery>

<CFPARAM name="Curr_Date" default="#now()#">

<CFIF isdefined("MonthChange")>
                     
                        <CFIF monthchange is 'forward'>
                       
            <CFSET curntdate = createodbcdate(dateadd("m", 1, lastdate))>
      <CFELSE>
            <CFSET curntdate = createodbcdate(dateadd("m", -1, lastdate))>
      </CFIF>
</CFIF>
<CFPARAM name="YearSet" default="#year(Curr_Date)#">
<CFPARAM name="MonthSet" default="#month(Curr_Date)#">

<!--- Create the date variables to search the Database by. --->
<CFSET monthstart = createdatetime(#yearset#, #monthset#, 1, 0, 0, 0)>
<CFSET monthend = createdatetime(#yearset#, #monthset#, #daysinmonth(monthstart)#, 23, 59, 59)>
        <CFQUERY datasource="calartscalendar" name="SearchResults">
              Select Eventname, EventDescription, Calendar_ID, CalendarDate From calendar Where CalendarDate >= #CreateODBCDate(monthstart)# and CalendarDate <= #CreateODBCDate(monthend)# <cfif #len(eventtype)#>and EventType = '#eventtype#'</cfif>
          </CFQUERY>
          <CFSET Lst_Eventname = Replace(ValueList(SearchResults.Eventname,'~'),'~~','~ ~','All')>
          <CFSET Lst_EventDescription = Replace(ValueList(SearchResults.EventDescription,'~'),'~~','~ ~','All')>
          <CFSET Lst_Calendar_ID = ValueList(SearchResults.Calendar_ID,'~')>
          <CFSET Lst_CalendarDate = ValueList(SearchResults.CalendarDate,'~')>
          <CFPARAM NAME="curr_date" DEFAULT="#CreateDate(Year(Now()), Month(Now()), Day(Now()))#">
                    <CFSET Lst_CalendarDay = "">
          <CFLOOP FROM="1" TO="#ListLen(Lst_CalendarDate,'~')#" INDEX="day_index">
               <CFSET Lst_CalendarDay = ListAppend(Lst_CalendarDay,day(dateformat(ListGetAt(Lst_CalendarDate,day_index,'~'),'mm/dd/yyyy')),'~')>
          </CFLOOP>

         
          <TABLE width="722" border="0" cellspacing="0" cellpadding="0"> <TR>
                    <TD align="left" valign="top" width="41">&nbsp;</TD>
                    <TD align="left" valign="top" width="630"><BR>
                    <TABLE width="558" border="0" cellspacing="0" cellpadding="2">
                         <TR>
                              <TD align="left">
                              <SPAN class="calendarbold_big"><CFOUTPUT>#DATEFORMAT(CURR_DATE, "mmmm yyyy")#</CFOUTPUT></SPAN></TD>
                              <TD align="right">
                              <SPAN class="calendarbold_big"><A HREF="index.cfm?Curr_Date=<CFOUTPUT>#DateAdd('m',-1,CURR_DATE)#</CFOUTPUT>"><span class="calendarbold_arrows"><font size="6">&#8249;&#8249;</font></span></A>  <A HREF="index.cfm?Curr_Date=<CFOUTPUT>#DateAdd('m',1,CURR_DATE)#</CFOUTPUT>"><span class="calendarbold_arrows"><font size="6">&#8250;&#8250;</font></span></A></SPAN></TD>
                         </TR>
                    </TABLE><BR>
                  <TABLE width="600" border="0" cellspacing="0" cellpadding="6">
              <TR align="left">
                              <TD valign="top" width="80" height=""><SPAN class="calendarbold"><FONT color="#000000">S</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">M</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">T</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">W</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">T</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">F</SPAN></TD>                              
                              <TD valign="top" width="80" height="0"><SPAN class="calendarbold"><FONT color="#000000">S</SPAN></TD>
                         </TR>
                         <TR bgcolor="#FFFFFF">
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>                              
                              <TD align="left" valign="top" width="80" height="2"></TD>
                         </TR>
                         <TR>
                              <!--- just change curr_date value as per date passed --->
                              <CFSET I_ROWCNT = 1>
                              <CFSET I_ROWNO     = 1><!--- WILL HOLD THE N0 0F ROWS DISPLAYED IN CALENDAR. --->                                                  
                              <CFLOOP FROM="1" TO="#Evaluate(DayOfWeek(CreateDate(Year(Curr_Date), Month(Curr_Date), 1))-1)#" INDEX="i_empty"><!--- put empty spaces till the first day of month comes eg. in case of May..there would be four empty spaces. --->
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                             </CFLOOP>
                              <CFSET I_ROWCNT = I_EMPTY>                              
                              <CFLOOP FROM="1" TO="#DaysInMonth(Curr_Date)#" INDEX="i_day">                                                                                          
                                   <CFIF ListFindNoCase(Lst_CalendarDay,i_day,'~') NEQ 0>
                                        <TD bgcolor="#F1E39E" align="left" valign="top" width="80" height="80"><SPAN class="calendarbold"><CFOUTPUT>#i_day#</CFOUTPUT></SPAN><BR>                                  
                                        <SPAN class="frontcopy"><cfset myUrl = urlencodedformat(#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#)>
<cfoutput>
<a href="event.cfm?Eventname=#myUrl#">#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#</a> </cfoutput></A><BR></TD>    
                                   <CFELSE>                                        
                                        <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold"><CFOUTPUT>#i_day#</CFOUTPUT></SPAN><BR></TD>
                                   </CFIF>                                  
                                   <CFIF I_ROWCNT MOD 7 EQ 0>
                                        </TR>
                                        <TR bgcolor="#FFFFFF">
                                             <TD align="left" valign="top" colspan="13" height="2"></TD>
                                        </TR>
                                        <TR>
                                        <CFSET I_ROWNO = IncrementValue(I_ROWNO)>
                                   </CFIF>
                                   <CFSET I_ROWCNT = IncrementValue(I_ROWCNT)>
                              </CFLOOP>
                         </TR>
                         <CFIF I_ROWNO LT 6><!--- hide this row in no. of rows is 6 --->
                              <TR>
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>                                  
                                   <TD align="left" valign="top" width="80" height="80"><SPAN class="calendarbold">&nbsp;</SPAN><BR></TD>
                              </TR>
                         </CFIF>                        
                    </TABLE></TD>
               </TR>
          </TABLE>
     <CENTER><IMG src="http://calarts.edu/images/redcat/buildings/seasondarkgray.gif" width="640" height="359" alt="" border="0"></CENTER></TD>
     </TR>
</TABLE>
</BODY>
</HTML>
0
phillystyle123
Asked:
phillystyle123
2 Solutions
 
anandkpCommented:
show me how ur list "Lst_eventname" looks when u have 2 events on the same day ....

u'll just have to loop over the events & display them inside the TD - so as to be able to show multiple events on the same day.

K'Rgds
Anand
0
 
hartCommented:
Anands right :-)
since he doesn't have the code, i have just pasted what he means by looping over events

change this part in your code

<SPAN class="frontcopy"><cfset myUrl = urlencodedformat(#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#)>
<cfoutput>
<a href="event.cfm?Eventname=#myUrl#">#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#</a> </cfoutput></A><BR>


to this

                        <CFIF ListValueCount(Lst_CalendarDay,i_day,'~') GT 1>
                                                                  <CFLOOP FROM="1" TO="#ListLen(Lst_CalendarDay,'~')#" INDEX="event_index">
                                                                        <CFIF ListGetAt(Lst_CalendarDay,event_index,'~') Eq i_day>
                                                                              <cfset myUrl = urlencodedformat(ListGetAt(Lst_EventName,event_index,'~'))>                                                                              
                                                                              <SPAN class="frontcopy"><cfoutput><a href="event.cfm?Eventname=#myUrl#">#ListGetAt(Lst_EventName,event_index,'~')#</a></cfoutput><BR>
                                                                        </CFIF>                                                                        
                                                                  </CFLOOP>
                                                            <CFELSE>
                                                                  <cfset myUrl = urlencodedformat(ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~'))>
                                                                  <SPAN class="frontcopy"><cfoutput><a href="event.cfm?Eventname=#myUrl#">#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#</a></cfoutput><BR>
                                                            </CFIF>


Regards
Hart


0
 
phillystyle123Author Commented:
thanks experts!  works perfectly!!!!!!
0
 
mattimeikalainenCommented:
I have also quite similar calendar application, but i have problems with event.cfm page. It also passes urlencodedformat url parameter to the action page (event.cfm) , but it doesn't work!

Here is my calendar page code where It  passes url parameter:

<cfset minunUrl = urlencodedformat(ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~'))>
<cfoutput><a href="event.cfm?eventName=#minunUrl#">#ListGetAt(Lst_Eventname,ListFindNoCase(Lst_CalendarDay,i_day,'~'),'~')#</a></cfoutput><BR>
 </CFIF>


Here is event.cfm code:
<CFQUERY NAME="SearchResults" DATASOURCE="galleryesim">
SELECT *
FROM kalenteri
WHERE eventName = #url.eventName#
</CFQUERY>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<cfoutput query="SearchResults">
<table border="0" cellpadding="0">
  <tr>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td>#eventDescription#,#eventName#</td>
    <td></td>
    <td></td>
  </tr>
</table>
</cfoutput>



</body>
</html>


0
 
anandkpCommented:
mattimeikalainen : put up a seperate q's for urself !
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now