database-driven gallery, with folders, subfolders,

Results 1 to 2 of 2

Thread: database-driven gallery, with folders, subfolders,

  1. #1
    Join Date
    Dec 1969

    Default database-driven gallery, with folders, subfolders,

    Hi, I&#039;m working on a database-driven photo gallery, in which a user will be able to create folders, and upload pictures into them. My problem is related to how the folders and images will be displayed. Let&#039;s say that I want to have 10 items (both folders and pictures) displayed per page, and when there are more, a Next/Previous link should be displayed at the bottom of the page. So if a user has 6 subfolders and 7 pictures, then he should see all the 6 subfolders, plus 4 pictures, and with the "next" link he should go to page 2, where he will see the remaining 3 pictures.<BR><BR>I have done half of the job, i.e. displayed the folders in several pages, with this code:<BR><BR> &#039;&#039; pg is the page number<BR> pg=request("pg")<BR><BR> If pg="" then<BR> pg = 1<BR> end if<BR><BR> &#039;&#039;&#039; psize = page size, i.e. maximun_items_per_page<BR> psize=request("psize")<BR><BR> If psize="" then<BR><BR> psize = 10<BR><BR> end if<BR><BR><BR> rs_folders.Open SQL_folders, cn, adOpenForwardOnly, adLockOptimistic, adCmdText<BR><BR><BR> rs_folders.pagesize=psize<BR><BR> maxpages=int(rs_folders.pagecount)<BR> maxrecs=int(rs_folders.pagesize)<BR><BR> rs_folders.absolutepage=pg<BR><BR>... and at the end of the page, after the folders are displayed, I use:<BR><BR>&#060;% if pg&#060;&#062;1 then %&#062;<BR><BR> &#060;a href=nasos.asp?state=2&pg=&#060;%=pg-1%&#062;&psize=&#060;%=psize%&#062; class=link&#062;Previous&#060;/a&#062;<BR><BR>&#060;% end if %&#062;<BR><BR>&#060;% if pg-maxpages&#060;&#062;0 then %&#062;<BR><BR> &#060;a href=nasos.asp?state=2&pg=&#060;%=pg+1%&#062;&psiz e=&#060;%=psize%&#062; class=link&#062;Next&#060;/a&#062;<BR><BR>... so that the next / previous links are shown.<BR><BR>Is there an easier way to do this task? The above code works, but it is only related to folders. And even I wrote the code which calculates the remaining images that can be displayed on the last folder page, I have problems when moving to the next pages where only the pictures will be shown.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: database-driven gallery, with folders, subfold

    What I would do is to load the whole lot into an array, ie. folder names, folder paths, picture names and picture paths (I&#039;m assuming you&#039;re talking about an actual folder structure somewhere) adding all the folders first and then all the pictures. Now these can be displayed in whatever manor you like by enumerating through the array.<BR><BR>To display only 10 at a time, set a variable, say &#039;startpoint&#039; which initially is zero and loop through the array from startpoint to startpoint+10. Then, make it so when the user clicks the next button the same page is called again but passed the number 10 which you set as the new startpoint. If they now click back, make sure they pass the number zero again. <BR><BR>hth.<BR>Pete.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts