Forum Moderators: open

Message Too Old, No Replies

Thumbnail Layout

Need to know how to get thumbnails to appear in table format

         

Meyer9

7:11 am on Sep 21, 2003 (gmt 0)

10+ Year Member



I've got my image gallery to finally work! Thanks to all who helped me. <snip> . But now I have a new question.

How do I get thumbnails extracted from a database to appear in individual cells. Here is an example of what it needs to look like. <snip>

I don't want to have to manually enter the html into the page whenever I add a picture into the database.

Thanks,

Brandon

[edited by: Xoc at 9:53 am (utc) on Sep. 21, 2003]
[edit reason] snipped urls [/edit]

plumsauce

11:05 am on Sep 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




That's why you're on IIS.

Use asp scripting to genereate dynamic pages.

++++

Meyer9

10:14 pm on Sep 21, 2003 (gmt 0)

10+ Year Member



Since I cannot provide links to an example of how I would like the images to appear, I've put together a text image.

I need a table with 42 cells, 6 cols and 7 rows.

-------------------------------
¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ 1 ¦ 2 ¦ 3 ¦ 4 ¦ 5 ¦etc.¦
-------------------------------
¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ 7 ¦ ...¦ ¦ ¦ ¦ ¦
-------------------------------
¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ ¦ ¦ ¦ ¦ ¦ ¦
-------------------------------
¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ ¦ ¦ ¦ ¦ ¦ ¦
-------------------------------
¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ ¦ ¦ ¦ ¦ ¦ ¦
-------------------------------
¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ ¦ ¦ ¦ ¦ ¦ ¦
-------------------------------
¦ ¦ ¦ ¦ ¦ ¦ ¦
¦ ¦ ¦ ¦ ¦ ¦ ¦
-------------------------------

How should I write the script to make it appear this way?

Thanks,

Brandon

mattglet

9:13 pm on Sep 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



loop through the database, using a counter to track how many images you've looped through. when the desired number is reached, insert a </tr> tag.

i don't have the time to do the code, but hopefully i gave you a track to start on.

-Matt

f00sion

9:44 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



for i = 1 to 7
response.write "<tr>"
for j = 1 to 6
response.write "<td>"
response.write '** some code for your images here
response.write "</td>"
next
response.write "</tr>"
next

aspdaddy

9:58 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay if you always have 42 images in the database ;)

Another way:

Response.write "<table>"
colCount=6 ' set number of columns
cols = 0
While not rs.eof

Path=rs("Path")

if cols=0 then
Response.write "<tr><td><img src=/gallery/" & Path & "></td>"
elseif cols mod colCount =0 then
Response.write "</tr><tr><td><img src=/gallery/" & Path & "></td>"
else
Response.write "<td><img src=/gallery/" & Path & "></td>"
end if

cols=cols+1
rs.MoveNext
wend
Response.write "</table>"

davegerard

5:11 am on Sep 27, 2003 (gmt 0)

10+ Year Member



Will the rows ever be more or less than 7? Do you need the whole table to be dynamic? I have some code for just that. How about 6 columns and unlimited rows? You can stop it at 42 images if you need. Let me check my schtuff...brb

[edited by: davegerard at 6:02 am (utc) on Sep. 27, 2003]

davegerard

6:01 am on Sep 27, 2003 (gmt 0)

10+ Year Member



Got it! This code assumes you have a folder called "thumbnails" inside of the folder you're working out of. It counts all of the images in the thumbnails folder and displays them. If you don't want anything showing up, just remove it from the folder. At least it's a start. Let me know how this works for you.

<html>

<body>
<table border="0" width="400" cellspacing="0" cellpadding="0">

<%
set fso = server.createobject("Scripting.FileSystemObject")
set MyFolder = fso.GetFolder(Server.MapPath("thumbnails"))

Dim Thumbnail()
for each file in MyFolder.files
ImageCount = ImageCount + 1
next
response.write "ImageCount: " & ImageCount & "<br>"

ReDim Thumbnail(ImageCount)
count=0
for each file in MyFolder.files
Count=Count+1
Thumbnail(Count) = file.name
'response.write Thumbnail(Count) & "<br>"
next

for n = 1 to ImageCount
%>

<tr>
<td width="100" height="100"><%if n <= ImageCount then%><img src="thumbnails/<%=Thumbnail(n)%>"><%n=n+1%><%end if%></td>
<td width="100" height="100"><%if n <= ImageCount then%><img src="thumbnails/<%=Thumbnail(n)%>"><%n=n+1%><%end if%></td>
<td width="100" height="100"><%if n <= ImageCount then%><img src="thumbnails/<%=Thumbnail(n)%>"><%n=n+1%><%end if%></td>
<td width="100" height="100"><%if n <= ImageCount then%><img src="thumbnails/<%=Thumbnail(n)%>"><%n=n%><%end if%></td>
</tr>

<%
next
%>

</table>
</body>

</html>