Want to Display the database values in 3 columns.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chinni1
    New Member
    • Nov 2008
    • 24

    Want to Display the database values in 3 columns.

    Hii..
    Im retreving the data from database using table1.so im taking the values in array.
    so using loop im displaying the values in single line .like
    one
    two
    three
    four
    five
    ...
    ...
    ...

    But i want to display the values like..
    one two three
    four five six
    .. .. ..

    my code is here..
    Code:
     <table>        
    <tr> 
    <td >Numbers</td>                
    </tr><%
    For cnt=1 To UBound(arrayobjrs, 2)+1 Step 1
    %>
    <tr>
    <td ><a href="home.asp?page=numb&id=<%=arrayobjrs(0, cnt-1)%>">&nbsp;<%=arrayobjrs(1, cnt-1)%></a></td>
    </tr>
    <%
    Next %>
    </table>
    Thanks
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    This seems a little overly complicated to me now that I wrote it out, but its been several years since I messed with classic ASP

    But in what your describing you might be able to use something like this inside your for loop

    Code:
    	Select Case cnt
    	   Case 1
    		Response.write "<tr><td>"
    	   Case 2,3
     		'Keep the same row but start a new column
    		Response.Write "<td>"
    	   Case 4
    		'start a new row
    		Response.write "<tr><td>"
    	   Case 5,6
     		'Keep the same row but start a new column
    		Response.Write "<td>"	
    	End Select

    Comment

    • jhardman
      Recognized Expert Specialist
      • Jan 2007
      • 3405

      #3
      Jeff's reply will work, but will get longer and longer the more objects in your array. Try this instead:
      Code:
       <table>        
      <tr> 
      <td >Numbers</td>                
      </tr><tr><%
      dim x
      x=0
      For cnt=1 To UBound(arrayobjrs, 2)+1 Step 1 %>
         <td ><a href="home.asp?page=numb&id=<%=arrayobjrs(0, cnt-1)%>">&nbsp;<%=arrayobjrs(1, cnt-1)%></a></td>
         <% 
         if x = 2 then %>
            </tr><tr>
         <%
         end if
      
         x = x + 1
         if x = 3 then x = 0
      Next %>
      </tr></table>
      Jared

      Comment

      Working...