----- Original Message -----
From: "Mark Smeets" <[EMAIL PROTECTED]>
> I'm trying to write a daily/weekly quote generator. I've got the code that
> pulls a random quote from my database however I'm not sure how to go about
> pulling it out every week or every day. (I'd like to be able to
interchange
> from a week to daily)
----------------------------

I've just built a "quote of the day" system:

In Application.cfm, I check for the existence of
application.quoteOfTheDay.timestamp. If it doesn't exist, or it exists and
it's older than a day (this can be changed of course), I query the quote DB
table and select all records.

Then I set application.quoteOfTheDay like this:

<cfoutput query="getAllQuotes"
startrow=#RandRange(1,getAllQuotes.recordcount)# maxrows=1>
    <cflock scope="APPLICATION" type="EXCLUSIVE" timeout="10">
    <cfscript>
     application.vars.quoteOfTheDay = StructNew();
     application.vars.quoteOfTheDay.quote = quote;
     application.vars.quoteOfTheDay.source = source;
     application.vars.quoteOfTheDay.timestamp = Now();
    </cfscript>
    </cflock>
</cfoutput>

Then just output the application variable on your page.

HTH,

- Gyrus

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- [EMAIL PROTECTED]
work: http://www.tengai.co.uk
play: http://www.norlonto.net
- PGP key available
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

Reply via email to