Or try...

<cfquery...>
        SELECT TOP 5 *
        FROM table
        ORDER BY NEWID()
</cfquery>

I think that will work on SS2k.

Ade

-----Original Message-----
From: Paul Swingewood [mailto:[EMAIL PROTECTED]
Sent: 08 September 2004 17:03
To: [EMAIL PROTECTED]
Subject: [ cf-dev ] A new problem ???


Can anyone help me with the logic for this one please ...

I have a table which has n number of pics in it....
I want to select 5 random pics (making sure that none are the same)
and then display them on the screen.

I have this muddled up code so far ....

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

<cfset piclist="">
<cfloop index = "LoopCount" from = "1" to = "5">
        <cfoutput query="GetPics">
                <cfset piclist=listappend(piclist,#id#)>
        </cfoutput>
        <cfset picnumber=randrange(1,listlen(piclist))>
        <cfset pictoget=listappend(listgetat(piclist,picnumber),#LoopCount#)>
</cfloop>

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

I've lost the plot completely and am confused as to what loop goes where,
when & why.

Regards - Paul



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


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