ODBiC Discussion Board


RE: There isn't really any direct way, Roger Harris, 04-24-2008

Sorry if I was vague, I have a solution.

by Adrian, April 29, 2008 02:04

Sorry if I was vague. I have a database storing filenames of pictures that belong in a gallery. I am making a page that will only show one of these pictures at a time, and has the ability, to see the 'next' picture, or the 'previous' one by the user clicking links.

This is the way I finally chose to naviagte through the pictures in the gallery. I either passed a querystring variable into the page to show a particular picture, or passed the ID of the last viewed picture through, plus which direction they were going in, to show the next, or previous picture in the database. This means they loop round so when they hit the last photo in the database they are forwarded round to see the first one again.

Here's the code for anyone's future refrence :

<%DATABASE "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=xxx.mdb; FIL=MS Access;";

If $lastViewed$; NOTE: The lastViewed variable only exists if the user is navigating through the records;

SELECT MAX(ID) As MaxID, MIN(ID) As MinID FROM tblGallery;

If $lastViewed$ = $MaxID$ AND $direction$ = "Next"; SET lastViewed = $MinID$-1; endif;

If $lastViewed$ = $MinID$ AND $direction$ = "Previous"; SET lastViewed = $MaxID$+1; endif; If $Direction$ = "Next"; SET Direction = ">"; SET ORDERBY = "ASC"; endif;

If $Direction$ = "Previous"; SET Direction = "<"; SET ORDERBY = "DESC"; endif;

SELECT filename, artist, ID FROM tblGal WHERE ID $Direction$ int($lastViewed$) ORDER BY ID $ORDERBY$; else; SELECT filename, artist, ID FROM tblGal WHERE ID = int($pic$); endif; %>

Sorry about the formatting on here!


Replies:


Post Your Reply:

Name   
E-mail  optional
Topic  
Message:

HTTP Link: 
Link text: 

          


Copyright ©1997-2003, Roger Harris. All rights reserved.