Or you could go one better and use a View.....or a temp table...there doesn't seem a need to generate a physical object to store the data.

 

N

 


From: Tom Smith [mailto:[EMAIL PROTECTED]
Sent: 09 September 2004 10:23
To: [EMAIL PROTECTED]
Subject: Re: [ cf-dev ] A new problem ???

 

you could stored the groups as numbers in the table, and then run:

 

select distinct group_id from tbl

 

Now do the ramdom code to get the group id you want

 

then continue with you code like:

 

<cfquery name="GetPics" datasource="#application.DSN#">
   select *
   from tblindexpics

    where group_id = #random_ID_set_earlier#
   order by ID desc
</cfquery>

 

----- Original Message -----

Sent: Thursday, September 09, 2004 10:13 AM

Subject: RE: [ cf-dev ] A new problem ???

 

Ok this all works fine and the client lioves it. Now of course whe wants a
change. There are n no of pics in the table which she now wants 'grouping'.
The idea is that when the images are randomly selected the five shown are
all from the same group. So lets say there are n groups. I guess it would
work something like this ....

Randomly select a group.
Now select five random images from that group only
display the images

How do I adjust the code earlier to achieve this

<cfquery name="GetPics" datasource="#application.DSN#">
   select *
   from tblindexpics
   order by ID desc
</cfquery>

<cfset PicIDList = ValueList(GetPics.ID)> <!--- Don't need this ?? --->

<cfset piclist="">
<cfloop index = "LoopCount" from = "1" to = "5">
   <cfset UniquePicID = false>
   <cfloop condition="NOT UniquePicID">
       <cfset picnumber=randrange(1,GetPics.RecordCount)>
       <cfset picID = GetPics["ID"][picnumber]>
         <cfif NOT ListFind(piclist,picID)>
            <cfset UniquePicID = True>
            <cfset piclist = ListAppend(piclist,picid)>
         </cfif>
   </cfloop>
</cfloop>

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



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

This e-mail is from Reed Exhibitions (Oriel House, 26 The Quadrant, Richmond, Surrey, TW9 1DL, United Kingdom), a division of Reed Business, Registered in England, Number 678540. It contains information which is confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender or call our switchboard on +44 (0) 20 89107910. The opinions expressed within this communication are not necessarily those expressed by Reed Exhibitions. Visit our website at http://www.reedexpo.com

Reply via email to