help: loop within a loop -how to display data in 3 columns by 4 rows format

A

addi

Well I got the data to display the way I wanted using the example provided
in the following links. Now I am stuck with another dilema. I am trying to
implement paging within my example and it does not seem to page thru. I have
used two independent examples (1 for paging, the other for displaying data)
and they both seem to work fine. When I combine them, it only processes the
first 9 records and paging does not seem to work. Any input on where the
code is broken would be greatly appreciated. The following is a working
example, using the pubs database in SQL Server.


<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=wbsql", "sa", "golf"

set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3 ' adUseClient
rs.Open "Select * from pubs..authors", conn
intPageCount = rs.PageCount
rs.PageSize = 9

Select Case Request("Action")
case "<<"
intpage = 1
case "<"
intpage = Request("intpage")-1
if intpage < 1 then intpage = 1
case ">"
intpage = Request("intpage")+1
if intpage > intPageCount then intpage = IntPageCount
Case ">>"
intpage = intPageCount
case else
intpage = 1
end select
%>
<table border="2" align=center>
<%
numCols = 3
intPage = rs.AbsolutePage
rsPageSize = rs.PageSize
i = 0

Do while i < rsPageSize
needFooter = true

if i mod numCols = 0 then
response.write "<tr>"
end if

response.write "<td align=center>"
response.Write "<P>" & rs(0) & "</P>"
response.Write "<P>" & rs(1) & "</P>"
response.Write "<P>" & rs(2) & "</P>"

response.write "</td>"

if i mod numCols = numCols - 1 then
response.write "</tr>"
needFooter = false
end if
i = i + 1
rs.MoveNext
Loop

if needFooter then
response.write "<td colspan=" &_
numCols - (i mod numCols) &_
"> </td></tr>"
end if
response.write "</table>"

rs.Close
set rs = Nothing
conn.Close
set conn = nothing
%>
</table>
<%

%>
<form name="MovePage" action="test1.asp" method="post" ID="Form1">
<input type="hidden" name="intpage" value="<%=intpage%>" ID="Hidden1">
<input type="submit" name="action" value="<<" ID="Submit1">
<input type="submit" name="action" value="<" ID="Submit2">
<input type="submit" name="action" value=">" ID="Submit3">
<input type="submit" name="action" value=">>" ID="Submit4">
Page: <%=Intpage & " of " & intpagecount%>
</form>
</BODY>
</HTML>


Best Regards,

Addi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top