Solved

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

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

740 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