Compairing a db record date with a dynamic calendar to make date into a hyperlink problem. Please help
Hello;
I need help. I have a dynamic calendar I have been writting. (I realize there are lots of free ones online but I needed one to do something else. this is only a part of the whole.I have everyhting working fine, it advances to the next month and looks really nice.I can't get my query to work. I had it throwing an error, but now it is just spitting out data I didn't want.I will post the code that is the problem, then the whole code for the calendar.
This is the problem code:
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID
FROM events
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>
<cfoutput>
<cfif thisday is day(now())>
<b>#ThisDay#</b>
<cfelse>
<cfif listFind(days,thisday)>
<a href="##"><b>thisday</b></a>
<cfelse>
#thisday#
</cfif>
</cfif>
</cfoutput>
this is the whole code for the calendar part:
<!--- Declaration of the variables --->
<cfparam name = "month" default = "#DatePart('m', Now())#">
<cfparam name = "year" default = "#DatePart('yyyy', Now())#">
<cfparam name = "currentday" default = "#DatePart('d', Now())#">
<cfparam name = "startmonth" default = "#DatePart('m', Now())#">
<cfparam name = "startyear" default = "#DatePart('yyyy', Now())#">
<!--- Set a requested (or current) month/year date and determine the number of days in the month. --->
<cfset ThisMonthYear = CreateDate(year, month, '1')>
<cfset Days = DaysInMonth(ThisMonthYear)>
<!--- Set the values for the previous and next months for the back/next links.--->
<cfset LastMonthYear = DateAdd('m', -1, ThisMonthYear)>
<cfset LastMonth = DatePart('m', LastMonthYear)>
<cfset LastYear = DatePart('yyyy', LastMonthYear)>
<cfset NextMonthYear = DateAdd('m', 1, ThisMonthYear)>
<cfset NextMonth = DatePart('m', NextMonthYear)>
<cfset NextYear = DatePart('yyyy', NextMonthYear)>
<cfset PreviousDay = DateAdd('d', -1, ThisMonthYear)>
<cfset CurrentYear = DatePart('yyyy', Now())>
<table border="0" width="100%" bgcolor ="#ffffff">
<tr>
<td align = "center" valign="top">
<table border="0" width="100%" height="100%">
<tr>
<th align="center" colspan="7" bgcolor="#2b4e6e">
<cfoutput>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15%" align="left" valign="middle">
<cfif (LastYear lt CurrentYear) OR (LastYear lte CurrentYear AND LastMonth lt startmonth)>
<cfelse>
<a href ="index.cfm?month=#LastMonth#&year=#LastYear#" class="calNav">Prev</a></cfif></td>
<td width="72%" align="center" valign="middle"><FONT SIZE="3" face="Arial, Helvetica, sans-serif" color="##ffffff">#MonthAsString(month)# #year#</FONT></td>
<td width="13%" align="right" valign="middle">
<cfif (NextYear lt CurrentYear) OR (NextYear lte CurrentYear AND NextMonth lt startmonth)>
<cfelse>
<a href = "index.cfm?month=#NextMonth#&year=#NextYear#" class="calNav">Next</a> </cfif></td>
</tr>
</table></cfoutput></th>
</tr>
<tr>
<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sun</FONT></td>
<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Mon</FONT></td>
<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Tue</FONT></td>
<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Wed</FONT></td>
<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Thu</FONT></td>
<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Fri</FONT></td>
<td><FONT SIZE="2" face="Arial, Helvetica, sans-serif" color="#333366">Sat</FONT></td>
</tr>
<cfset firstOfTheMonth = createDate(year(now()), month(now()), 1)>
<cfset endOfTheMonth = createdatetime(year(now()), month(now()), #daysinmonth(firstOfTheMonth)#, 23, 59, 59)>
<cfquery name="CaleventRec" datasource="#APPLICATION.dataSource#">
SELECT events.eventDate, events.ID AS ID
FROM events
Where eventDate Between #firstOfTheMonth# and #endOfTheMonth#
</cfquery>
<cfset ThisDay = 0>
<cfloop condition = "ThisDay LTE Days">
<tr class = "calendar">
<cfloop from = "1" to = "7" index = "LoopDay">
<!--- This turns each day into a hyperlink if it is a current or future date --->
<cfoutput>
<cfif thisday is day(now())>
<b>#ThisDay#</b>
<cfelse>
<cfif listFind(days,thisday)>
<a href="##"><b>thisday</b></a>
<cfelse>
#thisday#
</cfif>
</cfif>
</cfoutput>
<cfif ThisDay IS 0>
<cfif DayOfWeek(ThisMonthYear) IS LoopDay>
<cfset ThisDay = 1>
</cfif>
</cfif>
<!---If the ThisDay value is still 0, or is greater than the number of days in the month, display nothing in the column. Otherwise, dispplay the day of the mnth and increment the value.--->
<cfif (ThisDay IS NOT 0) AND (ThisDay LTE Days)>
<cfoutput>
<!--- I choose to highlight the current day of the year using an IF-ELSE. --->
<cfif (#ThisDay# EQ #currentday#) AND (#month# EQ #startmonth#) AND (#year# EQ #startyear#)>
<td align = "center" bgcolor="##FFFFCC">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
<cfelse>
<td align = "center">
<cfset dayview = #dateformat(createdate(#year#, #month#, #thisday#), "mm/dd/yyyy")#>
<font face="Arial, Helvetica, sans-serif" color="##000000" size="2">#ThisDay#</font>
</td>
</cfif>
</cfoutput>
<cfset ThisDay = ThisDay + 1>
<cfelse>
<td></td>
</cfif>
</cfloop>
</tr>
</cfloop>
</table>
</td>
</tr>
</table> </td>
</tr>
</table>
Can anyone help me with this? It is the last thing I need to get working and it is driving me crazy. Right now, this code does this:0
0
0
0
1
1
2
2
3
3
and then at the bottom of 32 numbers and doubles of numbers, is the calendar. So my llink code is making it do this.
Thank you!
I have to point out, it's pretty bad when Adobe is using jsp instead of coldfusion to run their forums.???????
