At the top of the page do this to create a list of all existing QuestionID's:
<cfquery name="qQuestionIDs">select QuestionID from Questions</cfquery>
<cfset QuestionIDs = ValueList(qQuestionIDs.QuestionID)>
Let's say you are currently at QuestionID = 3:
<cfset QuestionID = 3>
In the body, loop over the list of all existing QuestionID's until you find the
next existing question:
<!--- Initialize the loop --->
<cfset nextQuestionID = QuestionID>
<cfset nextIndex = 0>
<!--- Loop until next existing question is found --->
<cfloop condition="nextIndex EQUAL 0">
<cfset nextQuestionID = nextQuestionID + 1>
<cfset nextIndex = ListFind(QuestionIDs,nextQuestionID)>
</cfloop>
Now output the QuestionID of the next existing Question:
<cfoutput>The next existing Question after QuestionID #QuestionID# is
QuestionID #nextQuestionID#</cfoutput>
You can now construct a URL using nextQuestionID and send the user there via
CFLOCATION.
-David
P.S. I take it that in Example 1, you'd go to 5, not 3.
On Wednesday, June 06, 2001 4:32 PM, Mark Smeets [SMTP:[EMAIL PROTECTED]]
wrote:
> Here is what I want to do. I'm trying to check to see if the next
> QuestionID/Number exists(its an autonumber)
>
> If it does exist redirec the user to to that page
>
> If not, write some sort of way to loop adding numbers until it does find a
> number that exists.
>
> Example 1
>
> 1
> 2
> 3
> <-- 4 doesn't exist, so go to 3
> 5
> 6
>
> Example 2
>
> 1
> 2
> 3
> <-- 4 and 5 doesn't exist, so go to 6
> 6
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists