I'm trying to display a single random record from a recordset. Will this code work? I'm at work right now, and can't test it out.
<!--- BEGIN EXMAPLE --->
<cfquery name="random" datasource="datasource">
SELECT * FROM table WHERE random = True
</cfquery>
<cfset rec=Int(Random.RecordCount * Rand())>
<cfif rec EQ 0>
<cfset rec=1>
</cfif>
<cfoutput query="random" maxrows="1" startrow="#rec#">
output fields and whatever
</cfoutput>
<!--- END EXMAPLE --->
Well, that's what I've got right now. If anyone could let me know if that will work or if there is
a better way to do it, I'd really appreciate it.
Thanks in advance...
-b-
<!--- BEGIN EXMAPLE --->
<cfquery name="random" datasource="datasource">
SELECT * FROM table WHERE random = True
</cfquery>
<cfset rec=Int(Random.RecordCount * Rand())>
<cfif rec EQ 0>
<cfset rec=1>
</cfif>
<cfoutput query="random" maxrows="1" startrow="#rec#">
output fields and whatever
</cfoutput>
<!--- END EXMAPLE --->
Well, that's what I've got right now. If anyone could let me know if that will work or if there is
a better way to do it, I'd really appreciate it.
Thanks in advance...
-b-