Solved

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

Posted on 2007-12-03
5
434 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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now