Paul Swingewood wrote:

yup! - That seems to work ok.

Thanks a lot - Can't say I really understand how all that works but it seems to do what I wanted

Can't be having that!!!

<cfset PicIDList = ValueList(GetPics.ID)>

Can't remember why I did this - its not used anywhere - you can bin it! ahem.....


<cfset piclist=""> <cfloop index = "LoopCount" from = "1" to = "5">

Ok - loop until you have your five picture IDs.

   <cfset UniquePicID = false>
   <cfloop condition="NOT UniquePicID">

Condition to check that the pic ID that I'm getting in the next two lines of code is unique.

<cfset picnumber=randrange(1,GetPics.RecordCount)>

Picks a number between 1 and the total number of records in your query.

<cfset picID = GetPics["ID"][picnumber]>

Grabs the ID out of the query from the row you "randomly" picked and put in picnumber and chucks in the variable picID

         <cfif NOT ListFind(piclist,picID)>
            <cfset UniquePicID = True>
            <cfset piclist = ListAppend(piclist,picid)>
         </cfif>

If the picID that I've just grabbed from the query isn't in my list of ids, then tell the cfloop that I have a unique Pic ID and append it to the list.

   </cfloop>
</cfloop>

<cfquery  name="views" datasource="#application.DSN#">
   select *
   from tblindexpics
   where id IN (#piclist#)
</cfquery>

The IN operator allows you to select a bunch of records where ID is in the list placed between the brackets.

Of course, Adrian's solution is a hell of a lot better if you've got SQL Server - I'm reasonably certain that there is something similar in mySQL - just can't remember what it is right now.

Clear as mud?  Good... ;o)

Stephen


-- These lists are syncronised with the CFDeveloper forum at http://forum.cfdeveloper.co.uk/ Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by 
activepdf.com*
     *Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
          *Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*

To unsubscribe, e-mail: [EMAIL PROTECTED]



Reply via email to