Solved

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

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Coldfusion retrieve dynamic values 1 42
DNS, website, godaddy 6 94
change time in cron 4 101
cookies analysis tools 2 106
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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