From: <[EMAIL PROTECTED]>



>
> Last week there was a discussion about pulling a random quote from a database.
I would like to pull a record from a database once a week, lets say every
sunday. Kind of like the quote of the week.  Whats the best way to do that?
>

The page that displays the quote could have a section of code that looks at
the current day of the week and if it's Sunday - go get a new quote.

<cfif ((DayOfweek(Now() IS 1) AND (Hour(Now() IS 0))>
 go get a new quote
</cfif>

The above will get a new quote during the first hour of Sunday.
However, if the template is not run durng that hour a new quote will
not be retrieved. Likewise, if the template is run n times during that
hour then the quote will be refreshed n times.

It's necessary to
1: ensure the template runs at least once during the first hour of Sunday
2: ensure the timeplate runs only once during that time period.

You could narrow the time frame by checking for minute and seconds,
but the two problems remain.

2: is easy enought to deal with (e.g. query a lastUpdated filed in a db)
lots of ways to do that ..., but 1: remains

A scheduled task would work better - you can set those to run once week
at a specified time. Then, only if the server is down or if you have
a problem with the scheduler will the update fail.
A manual update page will solve that problem as long as you look at
the page that displays the quote on Sunday.

Alternatively, you could write a stored procedure or an embedded
query that checks the age of the last quote pulled from the db.

Alternatively (again), you could work with the lastmodified date of
the displaying page if it is a .html written from a dynamic .cfm.

In short, lots of ways to do this procedure - hope this stimulates
your thinking.

Pan

p.s problem solving skills and critical thinking methods are more
important than a collection of facts and howtos



------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to