You could query the table and get a list of the available IDs. Generate a random number between 1 and listlen() and then using ListGetAt() you can get that random ID and then query the DB again to pull back that record.
On 8/23/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > All, > > I'm doing a query and randomly displaying images from within each record > but records have been removed so I don't have sequential id values. > > PROBLEM: > When I run this code sometime I get images, sometimes I get nothing. > Should I be running a different random'izer? 8-) Any ideas? > > CODE: > <!--- GET 2ND VALUE TO BE PASSED TO RANDRANGE ---> > <CFQUERY name="get_vids_a" datasource="#datasource#" maxrows="1"> > select * > from vidweek > order by vidwee_id desc > </CFQUERY> > <!--- GET 1ST VALUE TO BE PASSED TO RANDRANGE ---> > <CFQUERY name="get_vids_b" datasource="#datasource#" maxrows="1"> > select * > from vidweek > order by vidwee_id asc > </CFQUERY> > <cfset VAL_ID = #RandRange(get_vids_b.vidwee_id, get_vids_a.vidwee_id, > "SHA1PRNG")#> > <!--- USE THAT ID VALUE TO SET IMAGE NAME ---> > <CFQUERY name="get_vids2" datasource="#datasource#"> > select vow_up_lgnail_file,vidwee_id,vow_title > from vidweek > where vidwee_id = #VAL_ID# > </CFQUERY> > <CFSET lgthbimg = "#get_vids2.vow_up_lgnail_file#"> > > <img src="VideoOfTheWeek/home/<cfoutput>#lgthbimg#</cfoutput>" width="262" > height="231" border="0"> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250753 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4