I am not sure why you are doing the second query... Why make the
*randomization* more complicated than it has to be???

Simplify:

<!--- GET 2ND VALUE TO BE PASSED TO RANDRANGE --->
<CFQUERY name="get_vids_a" datasource="#datasource#" maxrows="1">
select 
        vidwee_id
from 
        vidweek
</CFQUERY>

 <CFQUERY name="get_vids2" datasource="#datasource#">
   select vow_up_lgnail_file,vidwee_id,vow_title
   from vidweek
   where vidwee_id = #get_vids_a[ "vidwee_id" ][ RandRange( 1,
get_vids_a.RecordCount ) ]#
   </CFQUERY>

<CFSET lgthbimg = "#get_vids2.vow_up_lgnail_file#">

<img src="VideoOfTheWeek/home/<cfoutput>#lgthbimg#</cfoutput>" width="262"
height="231" border="0">


.......................
Ben Nadel 
www.bennadel.com

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 23, 2006 12:14 PM
To: CF-Talk
Subject: CFQUERY of non-swequential primary key ids

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:250748
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to