You can use ValueList(getids.id) to create a list of ids from the query, no
need to loop for that.

-----Original Message-----
From: Vinicius Caldeira Carvalho [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 27, 2000 3:07 PM
To: [EMAIL PROTECTED]
Subject: Re: Password protected directories


If you have gaps do the following:

<cfquery name=getids datasource=mydsn>
select ID from table
</cfquery>
<cfset ID_list ="">
<loop query=getids>
<cfset ID_List = #ListAppend(ID_List, ID)#
</cfoutput>

Now grab a position
<cfset Position = RandRange(1,#get_count.recordcount#)>

Grab the article

<cfquery name="get_art" datasource="someData">
select article from someTable
where ID = #ListGetAt(ID_List, position)#
</cfquery>

Using this you can have a list with following IDS 1,3,5,6
and garantee that all ID can be retreived.
[]'s

Vinicius Carvalho
-----Mensagem original-----
De: Alexander Lamon <[EMAIL PROTECTED]>
Para: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Data: Segunda-feira, 27 de Março de 2000 16:24
Assunto: RE: Password protected directories


>Robert,
>
>Are the primary keys you refer to below consecutive *and* contiguous?  If
>so, you can do something like this:
>
><!--- Get number fo records in the table --->
><cfquery name="get_count datasource="someData">
> select article from someTable;
></cfquery>
>
><!--- Grab a random number from this record count -->
><cfset randomID = RandRange(1,#get_count.recordcount#)>
>
><!--- Then grab the article with that matches this randomly chosen ID --->
><cfquery name="get_art" datasource="someData">
>select article from someTable
>where ID = #randomID#;
></cfquery>
>
>*However*, if you have gaps in the numbers like 1,2,3,7, this won't work
>for obvious reasons.
>
>Hope this helps,
>
>Alec Lamon
>IT Manager
>Wharton Direct
>
>
>> Ok here is my problem, I have a database that has news articles. Now what
>>my boss wants me to do is make it so the first feature story you see on
the
>>page is different each time you come on. It can be random and it can loop
>>over once you have seen all the feature articles. The problem is the only
>>unique field is the autonumber field so the feature articles could be
>>15,18,34,48,78. How would I be able to make it so each article is
different.
>>Anyone have something they have already done that I could use or modify?
>>
>>Robert Everland III
>>Network Administrator
>>Orlando.com
>>
>>--------------------------------------------------------------------------
>>----
>>Archives: http://www.eGroups.com/list/cf-talk
>>To Unsubscribe visit
>>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
>>send a message to [EMAIL PROTECTED] with 'unsubscribe' in
>>the body.
>---------------------------------------------------------------------------
---
>Archives: http://www.eGroups.com/list/cf-talk
>To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
>

----------------------------------------------------------------------------
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebarRsts&bodyRsts/cf_talk or send a message 
to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to