Don't know if its the easiest or best, but one way is
place your query output into an array
say qarray
Use RandRange() to generate random numbers
use CFloop to loop through array
Simple code:
<CFLOOP Condition=" Arraylen(qarray) GT 0>
<CFSET rnum = Randrange(1,Arraylen(qarray))>
#garray[rnum]#
ArrayDeleteAt[qarray,rnum]<!---clears that array element so each
company is only displayed once-->
</cfloop>
-----Original Message-----
From: Tom Forbes [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 10, 2001 3:45 PM
To: CF-Talk
Subject: How do I list query results in a random order fashion??
Dear Cf'ers:
I have the below query that gets companies alphabetically (stupid, eh?) -
the problem is, the companies don't like it because, being ordered by
company name, it gives preference to those that begin with the first
letters of the alphabet. Can anyone think of a way to order this list in a
random fashion each time it is envoked??
Thank you all for your consideration.
Tom
<CFQUERY NAME="GetAllCompaniesForThisCategory" DATASOURCE="MedMallDs"
DBTYPE="ODBC">
SELECT DISTINCT
JoinTbl.CategoryID, JoinTbl.CompanyID, CategoryTbl.CategoryName,
CategoryTbl.CategoryID, CompanyTbl.CompanyID, CompanyTbl.CompanyName,
CompanyTbl.WebAddress
FROM CategoryTbl, JoinTbl, CompanyTbl
WHERE
JoinTbl.CategoryID = CategoryTbl.CategoryID AND
JoinTbl.CompanyID = CompanyTbl.CompanyID AND
JoinTbl.CategoryID = #CategoryID# AND CompanyTbl.WebAddress IS NOT
NULL
ORDER BY CompanyTbl.CompanyName
</CFQUERY>
*****************************************************************
MedMatrix New & Used Medical Equipment Web Portal
http://www.medmatrix.com
V:(407) 772-3427 F:(407) 772-3428
Tom Forbes, Forbes Web Consulting, Inc.
178 S. Monterey Isle Blvd., Longwood, FL - 32779
*****************************************************************
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists