Print Page | Close Window

vertical - horizontal display

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=16008
Printed Date: 30 March 2026 at 6:24am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: vertical - horizontal display
Posted By: urko
Subject: vertical - horizontal display
Date Posted: 28 July 2005 at 7:45am
Me againConfused

How can I display my db records for example in horizontal display of 3-three and only then be transfer into next line??

thanks,



-------------
Urko



Replies:
Posted By: Misty
Date Posted: 29 July 2005 at 2:16am

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
    %>
 



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net