Paging records with multiple column table display help

Hi,

I have the code below which I edited to try to make a long story short. :)  The paging works fine when I make it one line per record, but when I try to change the value of the lines:

.PageSize = 2
if counter >= 3 then

it does not do what I think it will do.  If I put
.PageSize = 2
if counter >= 3 then

then it should only display only 2 records although it says there will be 3 records per row.

if I put
.PageSize = 24
if counter >= 2 then

Then I should have 24 records showing in rows of 2 on each page.

However, I cannot see what is wrong with the math here I guess.  It's so very confusing to me.  If anyone cares to take a look I would appreciate it greatly!



<%
    dim thisPage, rowcount, i
    thisPage = Trim(Request("thisPage"))
    if thisPage = "" then thisPage = 1
            Set conn = Server.CreateObject("ADODB.Connection")
            conn.Open xDb_Conn_Str      
            strsqlCFG1 = "SELECT * FROM TABLE"
                  
      Set rstempCFG1 = conn.execute(strsqlCFG1)
      if (rstempCFG1.eof) = true then
          Response.write "Nothing to show you."
      Else
Set rstempCFG1 = nothing
set rstempCFG1 = Server.CreateObject("ADODB.Recordset")

    with rstempCFG1
        .CursorType = adOpenStatic
        .PageSize = 3
        .Open "SELECT * FROM TABLE", conn
        .AbsolutePage = cINT(thisPage)

     end with
   rowCount = 0
    while not rstempCFG1.EOF and rowCount < (rstempCFG1.PageSize)
    %>
<table>
<tr>
<%
do until rstempCFG1.eof
%>
<td>Data will show here: <%=rstempCFG1("field")
</td>
  <%
     if counter >= 3 then
            counter = 0
      end if
       counter = counter + 1
     rstempCFG1.movenext
       %> <%
            rowCount = rowCount + 1
        loop
            if rstempCFG1.eof then
            response.write "</tr>"
            else
        rstempCFG1.MoveNext
        end if
        %> </td>
</tr>
</table>
<%
wend    
    Response.Write "<br clear=all>Next Page >"
    for i = 1 to rstempCFG1.PageCount
    %> <a href="page.asp?thisPage=<%=i%>"><%=i%></a> <% next %> <%
end if
end if
set rstempCFG1 = nothing
%>
JuniorBeeAsked:
Who is Participating?
 
GawaiCommented:
i post my code for paging. this will help u out.

''DB.asp
<%


      strDB4Search = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=;"
      strDB4Search = strDB4Search & "DBQ=e:\db\access.mdb"


 %>

''paging.asp

<!--#include file="inc/adovbs.inc"-->
<!--#include file="inc/Db.asp"-->
<%
Dim strDB4Search, objRs, objCon, strSQL
Const intPageSize = 5
strQ = Request.QueryString("q")

                        strSQL= "SELECT * FROM TblOverseas WHERE (City LIKE '%%"& strQ & "%%')  AND Price BETWEEN " & Request.QueryString("min") & " AND " & Request.QueryString("max")  & " AND BedRoom = " & Request.QueryString("bed") & " AND BathRoom = " & Request.QueryString("bath")

                        intCurrentPage = Cint(Request.QueryString("cp"))
                        Select Case Request.QueryString("s")
                              Case "Search"
                                    intCurrentPage = 1
                              Case "Previous"
                                    intCurrentPage = intCurrentPage - 1
                              Case "Next"
                                    intCurrentPage = intCurrentPage + 1
                              Case Else
                                    intCurrentPage = 1
                        End Select


                              Set objCon = Server.CreateObject ("ADODB.Connection")
                              objCon.Open strDB4Search
                              Set objRs = Server.CreateObject ("ADODB.Recordset")
                              objRs.Open strSQL, objCon,1,3
                              numOfRecords = objRs.RecordCount


                              If (objRS.EOF = False) And (objRS.BOF = False) Then
                                    objRS.PageSize = intPageSize
                              If Not(objRS.EOF) Then objRS.AbsolutePage = intCurrentPage
                                    intTotalPages = objRS.PageCount

                                    formatedPrice = FormatCurrency((objRs("Price")),2)

                                    For intI = 1 To objRS.PageSize

                                          Response.Write "<table border=0>"
                                          Response.Write "<tr>" & vbcrlf
                                          Response.Write "<td height=1>" & objRs("recordshere")
                                          Response.Write "</td>" & vbCrlf
                                          Response.Write "</tr>" & vbcrlf
                                          Response.Write "</table>"

                                          objRS.MoveNext
                                          If objRS.EOF Then Exit For
                                                Next
                                          numOfRecords = objRs.RecordCount


                                          Response.Write"<table align=center>"
                                          Response.Write"<tr>"
                                          Response.Write"<td>"
                                          If intCurrentPage > 1 Then
                                                Response.Write "<a href='" & Request.ServerVariables("SCRIPT_NAME") & "?q=" & Server.URLEncode(Request.QueryString("q")) & "&s=Previous" & "&cp=" & intCurrentPage &"'>Previous</a>"
                                          End If

                                          If (intCurrentPage > 1) And (intCurrentPage < intTotalPages) Then
                                                Response.Write "&nbsp;|&nbsp;"
                                          End If

                                          If intCurrentPage <> intTotalPages Then
                                                Response.Write "<a class='red9B' href='" & Request.ServerVariables("SCRIPT_NAME") & "?q=" & Server.URLEncode(Request.QueryString("q")) & "&s=Next" & "&cp=" & intCurrentPage & "'>Next</a>"
                                          End If

                                          Response.Write"</td>"
                                          Response.Write"</tr>"
                                          Response.Write"</table>"





                                          objCon.close
                                          Set objRs = Nothing
                                          Set objCon = Nothing


%>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.