If you're wanting rows to be sorted randomly, you should be doing this at
the database level. That's one of the items RDBMS's are really good at. For
SQL Server, check out the post below.

http://stackoverflow.com/questions/848872/select-n-random-rows-from-sql-server-table



On Fri, Jan 11, 2013 at 4:17 PM, B Griffith <br.griff...@yahoo.com> 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:353835
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to