Because that is what you ate telling it to do. Start from row x, and then output the next 4 rows. If you want to get 5 random rows then you need to create a loop from 1 to 5, inside that loop generate your random number, then get that row.
To get a specific row from a query use Queryname[row].column Or it might be Queryname["column name"][row] I forget the exact syntax. Regards Russ Michaels www.michaels.me.uk www.cfmldeveloper.com - Free CFML hosting for developers www.cfsearch.com - CF search engine On Jan 11, 2013 10:17 PM, "B Griffith" <[email protected]> wrote: > > Hello all! I am new to ColdFusion and web development in general, and > have only had cursory training in programming (Python). > > I have a need for a web page that will accept either an absolute number or > percentile from the end-user (I'm still having trouble w/ the 'form' > functionality of HTML), and then set the variable (or parameter?) "rows" to > the number chosen, then choose THAT number of records at random from the > database (MSSQL). Then I would like to display them (in no particular > order) in plain-old HTML, CSS and other stylization is not important at > this point, solely the functionality of the page. Here is my code: > > <cfquery name="rs" datasource="#application.dsn#"> > SELECT * FROM DONOR > </cfquery> > > <cfset displayRow = randRange(1,rs.recordcount)> > <cfparam name = "rows" default = "5"> > > <cfoutput query="rs" startrow="#displayRow#" maxrows="#rows#"> > <br /><h3>#displayRow# #first# #last# #flag#</h3><br /> > </cfoutput> > > The table name is 'DONOR', and the fields I want to display from it are > 'first', 'last', and 'flag'. I'm wondering at this point why when I run > the page, the output indeed picks a random record to start with, but then > displays the next four sequentially instead of choosing the other four at > random. I am more than happy to post a screencap of my browser output if > need be. Your help is much appreciated as I am quite stumped and I hope > you all can point me in the right direction. > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:353834 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

