I believe the best solution is to do the random pick in SQL, but, as a side
note, this code:

> <cfset RandNum = #RandRange(1,getrecords.RecordCount)#>
>
> <CFLOOP QUERY="getrecords">
>       <CFIF CurrentRow EQ #RandNum#>
>               <CFOUTPUT>
>                       Random Record No = #getRecordsrecord.ID#<BR>
>                       Quote = #getrecords.Quote#<BR>
>                       Author = #getrecords.Author#
>               </cfoutput>
>       </cfif>
> </cfloop>

should be written (or could be :) like so:

<cfset RandNum = #RandRange(1,getrecords.RecordCount)#>
<CFOUTPUT>Quote = #GetRecord.Quote[RandNum]#</CFOUTPUT>

Even cuter:

<CFOUTPUT>Quote =
#GetRecord.Quote[RandRange(1,getrecords.RecordCount)]#</CFOUTPUT>

Remember that you can treat a query like an array and access a particular
cell and row.

=======================================================================
Raymond Camden, Cold Fusion Jedi Master for Syntegra (www.syntegra.com)
Allaire Certified Instructor and Member of Team Allaire

Email   : [EMAIL PROTECTED]
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda

>
> <CFLOOP QUERY="getrecords">
>       <CFIF CurrentRow EQ #RandNum#>
>               <CFOUTPUT>
>                       Random Record No = #getRecordsrecord.ID#<BR>
>                       Quote = #getrecords.Quote#<BR>
>                       Author = #getrecords.Author#
>               </cfoutput>
>       </cfif>
> </cfloop>

=======================================================================
Raymond Camden, Cold Fusion Jedi Master for Syntegra (www.syntegra.com)
Allaire Certified Instructor and Member of Team Allaire

Email   : [EMAIL PROTECTED]
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda


> -----Original Message-----
> From: Larry Juncker [mailto:[EMAIL PROTECTED]]
> Sent: Monday, October 09, 2000 5:08 PM
> To: CF-Talk
> Subject: RE: random by day
>
>
> Why not this?
>
> <cfquery name="getrecords" datasource="MINE">
> SELECT *
> FROM QUOTES
> </cfquery>
>
> <cfset RandNum = #RandRange(1,getrecords.RecordCount)#>
>
> <CFLOOP QUERY="getrecords">
>       <CFIF CurrentRow EQ #RandNum#>
>               <CFOUTPUT>
>                       Random Record No = #getRecordsrecord.ID#<BR>
>                       Quote = #getrecords.Quote#<BR>
>                       Author = #getrecords.Author#
>               </cfoutput>
>       </cfif>
> </cfloop>
>
> Larry Juncker
> Senior Cold Fusion Programmer
> Heartland Communications Group, Inc.
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, October 09, 2000 3:50 PM
> To: CF-Talk
> Subject: random by day
>
>
>
> 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?
>
> KM
> ---------------------------------------------------
>
>
> ---------------------------------------------------
> Get free personalized email at http://www.iname.com
> ------------------------------------------------------------------
> ----------
> --
> 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.
>
>
> ------------------------------------------------------------------
> ------------
> 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.

------------------------------------------------------------------------------
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