Photo album pages

Previous and Next in Coldfusion

I have done this before when the data was clean and when I only needed to worry about one ID by just adding or subtracting one from the ID value. On my photo album pages I wanted to create a way to view my photos without lytebox. I have 2 IDs photo album and photo. Also my data is not the cleanest for example in my Denver photos I do not have a photo 1. I came up with a solution, not the most elegant I will admit. My work around for this problem includes looping the query to set the row number to a variable than instead of displaying against the photo ID I display against the row number. To create the next and previous I just add or subtract 1 from the row number. I also had to put a cfif to check to make sure my previous row variable was not -1. The code is below. You can see it in action here.

<cfloop query=“QPhotos”>
<cfif QPhotos.Photo_ID eq URL.PHOTO>
<cfset displayrow = QPhotos.currentrow>
</cfif> </cfloop>
<cfset nextrow = displayrow+1>
<cfset previousrow = displayrow-1>

<cfif previousrow GT 0><cfoutput query=“QPhotos” startrow=“#previousrow#” maxrows=“1”>

<cfoutput query=“QPhotos” startrow=“#displayrow#” maxrows=“1”>

<cfoutput query=“QPhotos” startrow=“#nextrow#” maxrows=“1”>

No Older Posts →
← No Newer Posts