Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 6th, 2005, 02:23 PM
Registered User
 
Join Date: Jun 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default recordset paging and display resultsets in columns

Hi,
How can I do the recordset paging and display the result sets in columns horizontaly?
The codes of paging and columns display do not match together.
One uses while statement and the other uses for-next.
I need to have both of them on a page.
Is it possible at all?

set rs=server.createobject("adodb.recordset")
Rs3.open "SELECT * FROM cards where cards.catid=" & intCatID & " and cards.subID=" & intSubID & " and cards.active=1",Conn,3,3

If Request.QueryString("page") = "" Then
    intPage = 1
Else
    intPage = Request.QueryString("page")
End If
RS3.PageSize = 10
intPageCount = RS3.PageCount
intRecordCount = RS3.RecordCount

 <%
                    If NOT (RS3.BOF AND RS3.EOF) Then
    If CInt(intPage) > CInt(intPageCount) Then intPage = intPageCount
    If CInt(intPage) <= 0 Then intPage = 1
        If intRecordCount > 0 Then
            RS3.AbsolutePage = intPage
            intStart = RS3.AbsolutePosition
            If CInt(intPage) = CInt(intPageCount) Then
                intFinish = intRecordCount
            Else
                intFinish = intStart + (RS3.PageSize - 1)
            End if
        End If

If intRecordCount > 0 Then
    For intRecord = 1 to RS3.PageSize

Dim link_rated
Dim link_rate_count
Dim link_rate_value


                      Dim NumRows,Index
NumRows = -2
index = 0
rs_NumRows = rs_NumRows + NumRows
startrw = 0
endrw = index
numberOFColumns =4
numrows = -1


while ((numrows <> 0) AND (Not rs3.EOF))
      startrw = endrw + 1
    endrw = endrw + numberOFColumns
    num=num+1




        while ((startrw <= endrw) AND (Not rs3.EOF))


                    %>
                      <TD vAlign=top align=middle class=text>
<BR>
                        <% if rs3("free")=True then %><IMG src="free.gif" border=0><a href="viewcard.asp?id=<%=rs3("cardid")%>"><IMG src="<%=rs3("thumbnail")%>" width="<%=rs2("thumb_width")%>" height="<%=rs2("thumb_height")%>" alt="<%=rs3("name")%>" border=0></a><IMG
                        class=Space_Border src="space.gif"
                        border=0><BR>
                        <%if rs3("type")="image" then%><IMG src="hs.gif" border=0><%else%><IMG src="ws.gif" border=0><%end if%><BR><a href="viewcard.asp?id=<%=rs3("cardid")%>"><%=rs3(" name")%></a><BR>Views:<%=rs3("views")%><%end if%>

                        <%if rs3("free")=False then %>
                      <IMG class=Space_Border src="space.gif" border=0><a href="viewcard.asp?id=<%=rs3("cardid")%>"><IMG src="<%=rs3("thumbnail")%>" width="<%=rs2("thumb_width")%>" height="<%=rs2("thumb_height")%>" alt="<%=rs3("name")%>" border=0></a><IMG
                        class=Space_Border src="space.gif"
                        border=0><BR>
                        <%if rs3("type")="image" then%><IMG src="hs.gif" border=0><%else%><IMG src="ws.gif" border=0><%end if%><BR><a href="viewcard.asp?id=<%=rs3("cardid")%>"><%=rs3(" name")%></a><BR>Views:<%=rs3("views")%>

                        <%
                        end if%>
                        </TD>
                            <%

startrw = startrw + 1
rs3.movenext
    wend

%>
</tr>
    <%
 numrows=numrows-1
 Wend

%>
<%

'rs3.movenext
If RS3.EOF Then Exit for
    Next
    %>

                    </TABLE></TD></TR>
              <TR class=titlebg>
                <TD width="100%" height=26>&nbsp;&nbsp; </TD></TR>
              <TR class=tblBG>
                <TD width="100%">
                </P></TD></TR></TBODY></TABLE></CENTER></DIV><br>
  <table width="759" border="0" cellpadding="0" cellspacing="0" class="text">
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="124">&nbsp;</td>
      <td width="729"><table width="617" border="0" cellpadding="0" cellspacing="0" background="images/bottom_bg.gif" class="text">
          <tr>
            <td width="11"><img src="images/bottom01.gif" width="11" height="22"></td>
            <td width="593" align="center" class="text">©
            2005 Keyvan1.com</td>
            <td width="13" align="right"><img src="images/bottom02.gif" width="13" height="22"></td>
          </tr>
        </table></td>
    </tr>
  </table>
</body>
</html>
<table border="0" cellpadding="0" cellspacing="0" width="75%" align=center>
<tr>
<td width="50%" align="center">&nbsp;
<%If cInt(intPage) > 1 Then%>
    <%= "<a href='show.asp?page=" & intPage-1 & "&catid=" & intcatID & "'>" & "<img src=images/back.gif border='0'>" & "</a>" %>
<%End If%>&nbsp;&nbsp;
<%
If cInt(intPage) > 1 or NOT rs3.EOF Then
             For intLinkPageNum = 1 to intPageCount
                If intLinkPageNum = intPage Then
            Response.Write vbcrlf & " " & intLinkPageNum
        Else
Response.Write "&nbsp;<a & href='show.asp?page=" & intLinkPageNum & "&catid=" & intcatID & "'>" & intLinkPageNum & "</a>&nbsp"
End If
    Next
End If
If cInt(intPage) < cInt(intPageCount) Then
response.write "<a href='show.asp?page=" & intPage+1 & "&catid=" & intcatID & "'>" & "<img src=images/next.gif border='0'>" & "</a>"
End If
%>
    </tr>
    </table>

<%
end if
end if
 rs.close
    set rs=nothing
 rs2.close
    set rs2=nothing
%>
 
Old March 7th, 2005, 07:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes you can do both! Here is the basic idea (I've left out a lot of your code so you can see the idea):
Code:
Rs3.open "...
...
numberOfColumns =4
columnsDone=0
Response.Write "<table><tr>"
For intRecord = 1 to RS3.PageSize
    ' write a column
    Response.Write "<td>" & RS3("fieldname") & "</td>"

    ' move and increment the count
    columnsDone = columnsDone + 1
    RS3.MoveNext

    ' start a new row?
    If columnsDone Mod numberOfColumns = 0 Then
        Response.Write "</tr><tr>"
    End If
Next
Response.Write "</tr></table>"
hth
Phil





Similar Threads
Thread Thread Starter Forum Replies Last Post
DB recordset paging using ajax paging? kumiko Classic ASP Basics 0 May 26th, 2008 10:23 AM
Recordset Paging incorrectly. Please help! phudong3da Dreamweaver (all versions) 4 October 4th, 2005 05:39 PM
Problem with recordset paging Stefania Classic ASP Databases 0 February 11th, 2005 08:59 AM
Getting error w/Paging through recordset Calibus Classic ASP Databases 3 September 2nd, 2004 06:41 PM
Problem in Recordset Paging zaeem Classic ASP Databases 2 October 15th, 2003 12:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.