Skip to main content
Inspiring
June 5, 2007
Question

retrieve name from cfdirectory query

  • June 5, 2007
  • 2 replies
  • 313 views
I am querying a folder of images using the cfdirectory tag. On my page if a url parameter is not present the code grabs the "name" value of the first item in the cfdirectory query and displays it. I also have code detecting the number of the current row and sets the value of the next image to 1 + the current row. I am passing that through a URL variable to the current page where a I want to grab the "name" value of the next image which is determined by the ordinal position based off the url variable. My problem is grabbing the name value based off a the ordinal position of the record in the query. How do I do this. I though of a query of queries but I don't know how to specifiy the ordinal position I want in the Where clause. Can it be done by treating the query as a structure or an array and if so what code would I used to grab the "name" value of row x?

Thanks,

Jason
This topic has been closed for replies.

2 replies

Inspiring
June 6, 2007
You can also use the startrow="" and maxrows="" attributes of <cfoutput> to set the start of your query output and how many rows you would like to display. It sounds like in your example maxrows would always be 1.
Participating Frequently
June 5, 2007
Use array notation

<cfdirectory action="list" directory="e:\isomeDirectory" name="qryDirectory">
<cfset name2 = qryDirectory.name[2]>