0

I am able to display my records from SQL Server db in a table. And now, I am trying to place them in 3 rows & 2 columns table. That's mean if there are two records in total, they should appear side by side instead of one after another. I can get is repeated records using the following code.

<%
Sub B00_DisplayRecords()
Do while not registerRS.eof
counter=counter+1
if counter=41 then
counter=0
counter=counter+1
end if
%>

<tr>    
   <th width="50" font class="tblhdr" style="width:400px;"><%=registerRS.Fields("SchoolId")%> - <%=registerRS.Fields("Organization")%></td>   
   <th width="50" font class="tblhdr" style="width:400px;"><%=registerRS.Fields("SchoolId")%> - <%=registerRS.Fields("Organization")%></td>   
</tr>    
<tr> 
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">ProductId: <%=registerRS.Fields("ProductId")%></td>
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">ProductId: <%=registerRS.Fields("ProductId")%></td>
</tr>
<tr>
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">Qty: <%=registerRS.Fields("Qty")%></td>
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">Qty: <%=registerRS.Fields("Qty")%></td>
</tr>
<tr>
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">Class: <%=registerRS.Fields("class")%></td>
   <td width="50" font class="pgcont" valing=left style="width:400px;" align="left">Class: <%=registerRS.Fields("class")%></td>
</tr>        

<%
registerRS.movenext
loop
registerRS.close
set registerRS=nothing 
End sub
%>  
1
  • You could just use line break. Doesn't look like any of the records will wrap. Do as I stated below to make columns but put each record in a single td Commented Nov 29, 2011 at 4:17

1 Answer 1

3
Do until rs.eof

    r = r + 1

    If r = 1 then
        Response.write "<tr>"
    End if

    ' data display

    If r = 3 then
        Response.write "</tr>"
    End if

    If r = 3 then r = 1

Rs.movenext
Loop

If r = 2 ' write extra td and end tr
If r = 1 ' write 2 td and end tr
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.