Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

spliting data into multiple tables 1

Status
Not open for further replies.

welshone

Programmer
Jul 30, 2001
414
GB
hello,
is this possible ?
I ran a query and the results are fed into a HTML table,
can I loop through the records and add 100 records to the html table then create a new table and add the next 100 records, then create another html and add the next 100 records and so on. ?
thank you very much for any help with this.
 
what you can do is put a counter in the loop code. Try this:

do until rs.eof

'increment i
i=i+1
'create a new table
if i = 1 then
response.write("<table>")
end if
'display data
response.write("<tr><td>"&...&"</td></tr>")
'close table and reset i to 0 so he can start counting againt starting from 1
if i = 100 then
response.write("</table>")
i=0
end if

movenext
loop

let me know if this is not what you are looking for.
 
hello Raplph,
thanks for the help, but i can't work out how to incorporate your code into mine, sofsar I have :

<BODY>
<%t=t+1%>
<%if t=1 then%>
<TABLE BORDER=1 BGCOLOR=#ffffff bordercolor=LightGrey CELLSPACING=0 CELLPADDING=3>
<%end if%>

<tr BGCOLOR="#808080" BORDERCOLOR=#000000>
<% for i= 0 to RS.Fields.Count - 1 %>
<th align="left"><FONT SIZE=1 FACE="Arial" COLOR=#ffffff><% = RS(i).Name %></font></th>
<% Next %>
</tr>

<% While Not RS.EOF %>
<tr>
<% for i= 0 to RS.Fields.Count - 1 %>
<td align="left"><FONT SIZE=1 FACE="Arial" COLOR=#000000><% = RS(i) %></font></td>
<% Next %>
</tr>



<%if t=100 then%>
</table>
<%t=0
end if %>

<%
RS.MoveNext
WEND
%>
</BODY>


where t is for the new tables.
 
paging recordsets faq333-3229

and search the forum for recordset paging there are quite a few threads



Chris.

Indifference will be the downfall of mankind, but who cares?
 
Try this:
<%
Dim objConn, objRs
set objConn = Server.CreateObject("adodb.Connection")
Set objRs = Server.CreateObject("Adodb.Recordset")
objConn.Open("dsn=[replace];uid=[Replace];pwd=[Replace];database=[Replace]")
objRs.ActiveConnection = objConn
objRs.Open("select * from [Replace]")
Do Until objRs.EOF
i=i+1
If i = 1 Then
Response.Write("<table BORDER=1 BGCOLOR=#ffffff bordercolor=LightGrey CELLSPACING=0 CELLPADDING=3>")
Response.Write("<tr BGCOLOR='#808080' BORDERCOLOR='#000000'>")
For Each col In objRs.Fields
Response.Write("<td>"&col.name&"</td>")
Next
End if
If i < 100 Then Response.Write("<tr>")
For Each row In objRs.Fields
Response.Write("<td>" & row.value & "</td>")
Next
If i < 100 Then Response.Write("</tr>")
If i = 100 Then Response.Write("</table>"):i=0
objRs.MoveNext():Loop
objRs.Close()
objConn.Close()
Set objRs = Nothing
Set objConn = nothing
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top