|
You may want to look at some code that I have for pictures that came from a database. I chose for only 4 of them to be displayed on one line.
Here's some code that might help you:
'Set sql string sqlString = "select * from Houses order by HouseID"
Const NUM_COLUMNS = 4 - Change this to 3 Dim EndOfRS Dim NumRecords, Temp1, Temp2, Temp3, i EndOfRS = 0 NumRecords = 0 & ;nbs p; 'Create a recordset set rs = Server.CreateObject("ADODB.Recordset") rs.CursorType = 2 rs.Open sqlString, connectionString
<% If Not rs.EOF then Do While Not rs.EOF NumRecords = NumRecords + 1 rs.MoveNext Loop
rs.MoveFirst
Do While NOT rs.EOF %> <tr> <% For i=1 to NUM_COLUMNS If rs.EOF Then EndOfRS = 1 Exit For End If
%> <td height="150" valign="top"><DIV ALIGN="center"> <table width="125" height="150" cellpadding="3" cellspacing="1" border="0" class="box1"> <!--DWLayoutTable--> <tr> & ;nbs p; <td align="center" bgcolor="ffffff" onmouseover="this.style.background='E3E0CF';" onmouseout="this.style.background='FFFFFF';"><a href="HomeGallery.asp?ID=<%=rs("HouseID")%>"><img src=../images/<%= rs("PhotoName") %> width="103" height="77" border="0"></a></td> </tr> </table> </div></td> <% If rs.EOF Then EndOfRS = 1 Exit For End If rs.MoveNext Next If EndOfRS = 0 Then rs.Move -NUM_COLUMNS If rs.BOF = True Then rs.MoveFirst End If End If If EndOfRS = 1 Then rs.MoveFirst Temp1 = InStr((NumRecords / NUM_COLUMNS), ".") Temp2 = Left((NumRecords / NUM_COLUMNS), Temp1-1) Temp3 = Temp2 * NUM_COLUMNS rs.Move Temp3 End If
For i=1 to NUM_COLUMNS If rs.EOF Then Exit For
rs.MoveNext If rs.EOF Then Exit For Next %> <% Loop %> <%end if %> %> <% rs.Close set rs = Nothing set ConnectionString = Nothing %>
|