Solved

Get ID of previous record and Next record during CFoutput of a query

Posted on 2007-12-03
5
464 Views
Last Modified: 2013-12-24
As i output a coldfusion query(multiple records) to the page how can i access the previous record and the next record as the data is written to the page?
0
Comment
Question by:ronayers
  • 2
  • 2
5 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 20396122
what you can do is the following
For  example you have a query qryTest
In order to get all records you do qryTest.recordcount, so if you need the record before you qryTest.recordcount -1 and qryTest.recordcount +1
try this approach and let me know if you need more help
0
 

Author Comment

by:ronayers
ID: 20396172
hhh...without testing it that doesnt look like it will work. i thikn that will only add one or subtract one from the record count. shouldnt i be able to do something like qrytest.recordid[i] orsomething like that?
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 20396196
check out this tutorila it is similar to what you need
http://tutorial20.easycfm.com/
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 20396731
If you want to refer back to the previous record or to the next record, you can treat the query's value like a structure..

Assuming your query is MyQuery and you have a field  myField.  This is how you can get the value of the previous record..

  MyQuery['myField'][myquery.curentRow-1]

and the next record...

  MyQuery['myField'][myquery.curentRow+1]

Of course, you have to put logic into place to be sure that you're not trying to fetch record zero or not trying to fetch a record beyond the last one..  
0
 

Author Closing Comment

by:ronayers
ID: 31412347
Thats it! thanks.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question