Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query database each day 1

Status
Not open for further replies.

Jami

Programmer
Jul 18, 2000
54
US
Hi all,
I have housed some trivia questions and answers for a member site I am developing. Each day, I would like a different question displayed. Can anyone give me direction on how I can query the database each day to pull up a different question. They are primary keyed with sequential numbers (i.e. 1 through 200..) Could I use cfscheduler?

Thanks!
Jami
 
Hi Jami.

You can use the RandRange function to return a random number:

<cfset msgid = #RandRange(1,200)#>
<cfquery name=&quot;getit&quot; datasource=&quot;whatever&quot;>
select * from database
where msgid = #msgid#
</cfquery>

You can execute the template using the scheduler. I have not had very good luck using the scheduler through ColdFusion Administrator, although it seems to work o.k. when I use the <cfschedule> tag:

<cfschedule
username=&quot;Administrator&quot;
password=&quot;whatever&quot;
action=&quot;update&quot;
task=&quot;scheduled elerts&quot;
operation=&quot;HTTPRequest&quot;
startdate=#datetorun#
starttime=&quot;02:00:00&quot;
url = &quot; interval=&quot;once&quot;>


Please put the username and password on. I could not make it work without it. Good luck.

snix1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top