Stepping through a CFLOOP, one record at a time

I am creating an online survey, where the questions are being generated from a database.  I want to display 1 question at at time (via CFFORM), get the answer for that questions, and write the answer to the answers table before I proceed to the next question.  Question:  How do I traverse through a CFLOOP, displaying one record at a time, only displaying the current record (i.e. displaying only record 3 of 10)?  Using the Query option will display all 10 records at a time, instead of displaying record 3 of 10 only.

Thanx,

P.S.  This is an awesome site!!!
WashDevSolutionsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SidFishesCommented:
something like...

<cfset start =1>
<CFOUTPUT query = "questions" startrow="#start#" maxrows="1">

<cfif nextX LTE questions.RecordCount>
<cfset nextx = start+1>
<a href="questions.cfm?/start/#nextX#/">  Next &gt;&gt; </a>
<cfelse>
Done!
</cfif>

#questions.qText#

</cfoutput>




0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SidFishesCommented:
oops

sb

<cfif start LTE questions.RecordCount>
0
WashDevSolutionsAuthor Commented:
Thanx SidFishes.

I found that using CFOUTPUT with the QUERY= option would display all the records, ignoring the MAXROWS option (thats ColdFusion for you, ignoring its own rules).  Although your solution did not work right out of the box, it did put me in the right direction.  I came up with the following code, which accomplished what I neded, using CFLOOP:

<!--- Note:  The name of this form is survey.cfm.  This code calls itself to display each question one at a time --->

<cfparam name="url.CurrentQuestionID" default=1>

<cfset Counter = #url.CurrentQuestionID#>
<cfset CounterNext = url.CurrentQuestionID + 1>

<CFloop query = "qGetQuestions" startrow="#Counter#" endrow="#Counter#">
      <cfif #Counter# LTE #qGetQuestions.RecordCount#>
            <form action="Survey.cfm?CurrentQuestionID=<cfoutput>#CounterNext#</cfoutput>" name="frmGetSurvey" method="post">
                  <!--- Code to display my question --->
                  <cfset Counter = #Counter# + 1>
            </form>
      </cfif>
</cfloop>

When you review this code, please review that the ENDROW and STARTROW must be the same in order for it to display 1 record at a time.  If I can figure out how to grant you the full point value for this question, I will.

Thanx for you help,
WashDevSolutions

0
SidFishesCommented:
not sure why the code i provided didn't work for the q as I use it  all the time with correct results, however given that the code helped in the eventual solution i think points should be awarded
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.