I am trying to create a form so that when the user access the page, this number is randomly created and displayed to the user. This number must be unique as well. So, not only do I need a random number, but it must be a random number that does not currently exist in the database.
Here is my code to generate the random number:
I am probably going about this all wrong. Any ideas???
Any help would be much appreciated. Thanks!
Here is my code to generate the random number:
Code:
<CFQUERY NAME="qNUMBER">
SELECT NUMBER
FROM TS.NUMBER
</CFQUERY>
<CFSET tempnum = #randrange(1, 10)#>
<CFLOOP CONDITION="qNUMBER.NUMBER DOES NOT CONTAIN #tempnum#">
<CFSET tempnum = tempnum>
<CFBREAK>
</CFLOOP>
<CFOUTPUT>#tempnum#</CFOUTPUT>
I am probably going about this all wrong. Any ideas???
Any help would be much appreciated. Thanks!