Skip to main content
Known Participant
October 18, 2007
Question

how to display data on a regular basis

  • October 18, 2007
  • 2 replies
  • 397 views
I have the following code and it works fine - but i want Cf to pull fresh random data every 24 hours - any ideas?

<cfquery name="qArticles" datasource="#mxajaxdata#">
SELECT ID, Image, Blurb
FROM Articles
</cfquery>

<cfset ShownList = "">

<!--- Start the output --->
<cfoutput>

<!--- Loop until we have shown four entries --->
<cfloop condition="ListLen(ShownList) LTE 4">
<!--- Use RandRange to pick an article --->
<cfset ArticleToShow = RandRange(1, qArticles.RecordCount)>

<!--- If this article is not in the list of items shown --->
<cfif NOT ListContains(ShownList, ArticleToShow>
<!--- Add this article ID to the list of ones shown --->
<cfset ShownList = ListAppend(ShownList, ArticleToShow)>

<!--- Now display the output --->
<a href="articles.cfm?id=#qArticles.ID[ArticleToShow]#">
<img src="#qArticles.Image[ArticleToShow]#" border="1"></a>
#qArticles.Blurb[ArticleToShow]#
<br />
<hr />
</cfif>
</cfloop>
</cfoutput>
This topic has been closed for replies.

2 replies

Inspiring
October 18, 2007
Just wanted to add that the Scheduled Tasks option is still under the Debugging and Logging section in CF8, which is an odd place for it :).
October 18, 2007
Look into using CFSchedule Tasks. It's in the CF Admin under (strangely enough) "debugging and logging" in CFMX 7 (not sure about 8). You can set a Task to hit your query page on a daily basis. Cool feature, I use it a lot.