SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2004
    Location
    UK
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question PLEASE HELP !!!!!! Recordset problem with AbsolutePage

    Dear all,

    I have this script for navigating through a recordset, it all works fine,
    except when I click to move to the next page
    it displays all results again rather than the results only for that page.

    I've tried every combination of Record cursor types etc. and still no joy.

    Could someone please help me.

    Kind Regards

    Damiano3


    <%@ LANGUAGE="VBScript" %>
    <% Option Explicit %>
    <!--#INCLUDE FILE="adovbs.inc"-->
    <%
    Dim pg, numpages, numrecs, pagesize, rowCount
    Dim theConnection,prodRS, sqlString,conString

    pg = TRIM( Request( "pg" ) )
    IF pg = "" THEN pg = 1
    If pg > numpages Then pg = numpages
    If pg < 1 Then pg = 1

    pagesize = TRIM( Request("recs") )
    If pagesize = "" Then pagesize = 9

    sqlString = " *********** Query ************** "
    conString=" ********* Database Connection ********** "

    Set theConnection = Server.CreateObject("ADODB.Connection")
    Set prodRS = Server.CreateObject("ADODB.Recordset")

    prodRS.CursorLocation = 3
    prodRS.CursorType = 3

    theConnection.Open conString
    prodRS.Open sqlString,theConnection

    prodRS.PageSize = pagesize
    prodRS.AbsolutePage = pg
    numpages = prodRS.PageCount
    numrecs = prodRS.RecordCount

    %>

    <html>
    <body>

    <%
    Response.Write("" & numrecs & " records found." )
    %>

    <BR>

    <FORM NAME="myform" METHOD="post" ACTION="results.asp">
    Display
    <SELECT NAME="recs">
    <OPTION VALUE=1> 1
    <OPTION VALUE=2> 2
    <OPTION VALUE=3> 3
    <OPTION VALUE=4> 4
    <OPTION VALUE=5> 5
    <OPTION VALUE=6> 6
    <OPTION VALUE=7> 7
    <OPTION VALUE=8> 8
    <OPTION VALUE=9> 9
    <OPTION VALUE=10> 10
    </SELECT>
    images per page
    <INPUT TYPE=submit VALUE="GO">
    </FORM>

    <BR>
    <%
    IF numpages > 1 THEN
    %>
    <font color="black" face="Univers">Page: </font>
    <font color="#811788" face="Univers">
    <%=pg %> of <%=numpages %>
    </font>

    <BR>
    <%
    dim i
    FOR i = 1 to numpages
    IF i <> cINT( pg ) THEN
    %>
    <a href="results.asp?pg=<%=i%>">
    <%=i%></a>&nbsp;
    <% ELSE %>
    <b><%=i%></b>&nbsp;
    <% END IF %>
    <% NEXT %>
    <% END IF
    %>

    <BR>
    <% IF pg = 1 THEN %>
    &nbsp;
    <% ELSE %>
    <% j = pg - 1 %>
    <a href="results.asp?pg=<%=j%>"><img src="leftarrow.jpg" border="0"></a>
    <% j = pg %>
    <% END IF %>
    <% IF (pg) = (numpages) THEN %>
    &nbsp;
    <% ELSE %>
    <% dim j %>
    <% j = pg + 1 %>
    <a href="results.asp?pg=<%=j%>"><img src="rightarrow.jpg" border="0"></a>
    <% j = pg %>
    <% END IF %>
    <BR>
    <%
    dim m
    FOR m = 1 to pagesize
    %>
    Ref#<%=prodRS( "image_id" )%>
    <%prodRS.movenext%>
    <% NEXT %>
    </body>
    </html>

  2. #2
    SitePoint Enthusiast BarbaraStreisand's Avatar
    Join Date
    Feb 2004
    Location
    New York
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It could have something to do with the fact that you are checking if pg>numpages before the number of pages is assigned to numpages. Also, pg is quite possibly not being compared as a numeric datatype there, since it was pulled generically from the Request variable. Whatever value and datatype the variable pg is holding will probably have a greater comparative value than the empty numpages variable, which would set the numpages variable to nothing, which leaves you on one. Sorry I'm just guessing, I'm too lazy right now to write up and execute an example

  3. #3
    SitePoint Member
    Join Date
    Aug 2004
    Location
    UK
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    I think you are right about the :

    Quote Originally Posted by BarbaraStreisand
    [fact that you are checking if pg>numpages before the number of pages is assigned to numpages.]
    This code needs to be in the script, but I don't know where, please you take a look again and try and help me towards a solution.

    (it may not be be this though :-))

    Kind Regards

    Damiano3


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •