Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-12-03
5
Medium Priority
?
526 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Supports up to 4K resolution!

The VS192 2-Port 4K DisplayPort Splitter is perfect for anyone who needs to send one source of DisplayPort high definition video to two or four DisplayPort displays. The VS192 can split and also expand DisplayPort audio/video signal on two or four DisplayPort monitors.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

730 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