> The thing about this is that there are could be hundreds of people to book
time slots with and
> they all have different days, different "office hours" and different length
of appointment times.
IMO, that sounds like all the more reason to use a database driven approach.
It is likely to be more flexible and reusable than hard coding. However, it
does take some thought and planning.
> Is there any way to have the cfif statement continually check against the
looping time
> slots from startTime to endTime?
CF_Output already mentioned most of the options: [i]..use an output query,
list, or loop against your recordset to compare against your times.[/i]. Each
has varying degrees of efficiency and accuracy. Except for the list option, it
would probably require a nested loop. Meaning for each time slot you would
loop through your query results, testing each record for a match. Not the most
efficient method, but here is psuedo code example.
<cfloop from="#startTime#" to="#endTime#" index="i"
step="#CreateTimeSpan(0,0,m,0)#">
...
<cfset isTimeSlotBooked = false>
<cfloop query="Recordset2">
Compare the current value in the query against the current time slot
If time slot is booked, set a flag and exit
<cfif ATimematchWasFound>
<cfset isTimeSlotBooked = true>
<cfbreak>
</cfif>
</cfloop>
<cfif isTimeSlotBooked >
Already booked
<cfelse>
Not booked
</cfif>
</cfloop>
Another option is to use a QoQ.
<cfloop from="#startTime#" to="#endTime#" index="i"
step="#CreateTimeSpan(0,0,m,0)#">
<!--- within each loop check your query to see if it contains
a booking for the current time slot --->
<cfquery name="checkTime" dbtype="query">
SELECT Something
FROM Recordset2
WHERE ..... your conditions here ...
</cfquery>
<cfif checkTime.recordCount GT 0>
reserved
<cfelse>
not reserved
</cfif>
</cfloop>
dwmart - 31 Jul 2008 04:22 GMT
Thank you ... your reply was very helpful :)