What if you write the ID of the previous set into a variable, then either
deny that set from within the next query, or simply test to see if it picked
the same one and if so, redo the query until it retrieves a set that does
not match the previous.  Does that make sense?  Did I understand the
question?

HTH!

~Val

----- Original Message -----
From: "Jeff Fongemie" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, January 31, 2002 3:40 PM
Subject: Get a random record, but not too random?


> Thursday, January 31, 2002, 3:32:59 PM
> Hello cf-talk,
>
>   I've got a layout that displays a random set of images on each page.
>
>   I have one to many DB setup, with image sets, and images
>   respectively. I first find a random set, then get the images for
>   that set. It works like this:
>
> <cfquery name="getcoverset"  datasource="#request.DSN#" dbtype="ODBC">
>     SELECT coverid
>     FROM coverpicsets
> </cfquery>
>
> <CFSET List = ValueList(getcoverset.coverid)>
> <CFSET Position = RandRange(1, ListLen(List))>
> <CFSET Randomset = ListGetAt(List, Position)>
>
> <CFQUERY name="set" datasource="#request.DSN#">
> SELECT *
> FROM coverpics
> WHERE coverid=(SELECT *
>                FROM coverpicsets
>                WHERE coverid = #Randomset#)
> </cfquery>
>
> <cfoutput query="set">#one# #two# #three# #four#</cfoutput>
>
>
>
> What I'm trying to do is have the random set, choose a set, but
> exclude set that was used on the previous page. I've tried setting the
> "randomset" as a parameter, and using it in an cfif statement, as in
> cfif randomset exists, then run the query exluding that random set, if
> not then just run the normal above query. However, it
> is not keeping random set from page to page.
>
> Am I going about this is the right way?
>
>
> Best regards,
>  Jeff Fongemie                          mailto:[EMAIL PROTECTED]
> 
______________________________________________________________________
Why Share?
  Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to