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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paging through RecordSets (URGENT)

Status
Not open for further replies.

NeoTurtle

Programmer
Aug 25, 2000
38
US
Hi everyone! Please help!! The paging through records is fine, but it keeps counting through all the pages!! I want to show only 10 pages at a time. I thought i just had to change the iPageCount to 10, but that didn't work =(

Code:
If iPageCurrent > 1 Then
Response.Write &quot;		<TD><A HREF=&quot;&quot;index.asp?page=&quot; & iPageCurrent - 1 & &quot;&sort=&quot; & Request(&quot;sort&quot;) & &quot;&quot;&quot;><IMG SRC=&quot;&quot;images/prev.gif&quot;&quot; BORDER=&quot;&quot;0&quot;&quot; ALIGN=&quot;&quot;absmiddle&quot;&quot;></A></TD>&quot; & vbCrLf
End If

For I = 1 To iPageCount
	If I = iPageCurrent Then
Response.Write &quot;<TD STYLE=&quot;&quot;font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12pt; font-weight: bold; color: #000000;&quot;&quot;>&quot; & I & &quot;</TD>&quot; & vbCrLf 
	Else
Response.Write &quot;	<TD><A HREF=&quot;&quot;index.asp?page=&quot; & I & &quot;&sort=&quot; & Request(&quot;sort&quot;) & &quot;&quot;&quot; STYLE=&quot;&quot;font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12pt; font-weight: bold; color: #FF9966; text-decoration: none;&quot;&quot;>&quot; & I & &quot;</A></TD>&quot; & vbCrLf
	End If
Next 'I

If iPageCurrent < iPageCount Then
Response.Write &quot;<TD><A HREF=&quot;&quot;index.asp?page=&quot; & iPageCurrent + 1 & &quot;&sort=&quot; & Request(&quot;sort&quot;) & &quot;&quot;&quot;><IMG SRC=&quot;&quot;images/next.gif&quot;&quot; BORDER=&quot;&quot;0&quot;&quot; ALIGN=&quot;&quot;absmiddle&quot;&quot;></A></TD>&quot; & vbCrLf
End If

Please help me ASAP!! I was gonna try to fix this, but we had problems with our webserver, so i had to take care of that. And all these other things keep coming up!! Thanks in advance for your help guys!!
 
<%
Dim conn,db_connectionstring,sql,rs,pict,movie,movieold,flag,arr(20)
position=request.form(&quot;position&quot;)
count=request.form(&quot;count&quot;)
v=request.form(&quot;v&quot;)

if v=&quot;&quot; then
v=1
end if
if position=&quot;&quot; then
position=&quot;1&quot;
end if
if count=&quot;&quot; then
count=&quot;0&quot;
end if
set conn=server.createobject(&quot;ADODB.connection&quot;)
db_connectionstring = &quot;driver={microsoft access driver (*.mdb)}; dbq=&quot; & server.mappath(&quot;../data/general.mdb&quot;)
conn.open db_connectionstring

'var thedate = new Date(year, month, date)
set rs=server.createobject(&quot;ADODB.RECORDSET&quot;)
sql=&quot;select * from guestbook order by date desc&quot;
set rs=conn.execute(sql)%>
<!--#include file=&quot;top.inc&quot;-->
<form method=&quot;post&quot; action=&quot;gbookupdated.asp&quot;>
<table border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; width=&quot;500&quot; cellspacing=&quot;0&quot;>
<tr>
<td colspan=&quot;2&quot;>
<div align=&quot;center&quot;><font size=&quot;4&quot; face=&quot;Arial, Helvetica, sans-serif&quot; color=&quot;white&quot;><B>GuestBook</b></font></div>
</td>
</tr>
<tr>
<td colspan=&quot;2&quot;>&nbsp;</td>
</tr>
<tr>
<td><font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot; color=&quot;white&quot;>Name:</font></td>
<td>
<input type=&quot;text&quot; name=&quot;name&quot;>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot; color=&quot;white&quot;>Email:</font></td>
<td>
<input type=&quot;text&quot; name=&quot;email&quot;>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;2&quot; color=&quot;white&quot;>Comments:</font></td>
<td>
<textarea name=&quot;comments&quot;></textarea>
</td>
</tr> <tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan=&quot;2&quot;>
<div align=&quot;center&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Guestbook&quot;>
</div>
</td>
</tr>
</table>
</form>


<form name=&quot;newrelease&quot; method=&quot;post&quot; action=&quot;guestbook.asp&quot;><%
if not rs.eof then
totalrec=0
do while not rs.eof
rs.movenext
totalrec=totalrec+1
loop
rs.movefirst
dim temp(200)
i=0
perpage=7
totalpage=int(totalrec/perpage)

If not totalpage=(totalrec/perpage) then
totalpage=totalpage+1
End if
counter=1
x=1
Do while not rs.eof
if ((counter mod perpage)=0)then
arr(x)=counter
x=x+1

end if
counter=counter+1
rs.movenext
loop
rs.movefirst


%>
<input type=&quot;hidden&quot; name=&quot;position&quot; value=&quot;<%=position%>&quot;>
<input type=&quot;hidden&quot; name=&quot;count&quot; value=&quot;<%=count%>&quot;>
<input type=&quot;hidden&quot; name=&quot;v&quot; value=&quot;<%=v%>&quot;>

<table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;Center&quot; >

<%
ct=cint(position)
ctx=ct
if v=1 then
rs.move 0
else
rs.move arr(v-1)
end if


do while not rs.eof
if ctx < (cint(position)+perpage) then

ctx=ctx+1
name=rs(0)
email=rs(1)
Comments=rs(2)
dt=rs(3)
pos=pos+1

%>
<tr bgcolor=&quot;#FFFFCC&quot;>
<td align=&quot;left&quot;><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;2&quot; color=&quot;black&quot;><b><%=name%></b>&nbsp;&nbsp;posted it on &nbsp;<%=dt%></font></td>
</tr><BR><Tr>
<td colspan=&quot;2&quot; align=&quot;left&quot;><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;2&quot; color=&quot;white&quot;><%=Comments%></font></td>
</tr><TR><TD>&nbsp;</td></tr>
<%rs.movenext

else
exit do
end if


loop%>
</table><%
For v = 1 to totalpage

If trim(position)<>trim(cstr(v*perpage-(perpage-1))) then
%>
<td width=&quot;16&quot; align=&quot;center&quot; valign=&quot;top&quot; align=&quot;Center&quot;><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;><b><a href='javascript:document.newrelease.position.value=<%=(v*perpage-perpage)+1%>;document.newrelease.count.value=&quot;<%=count%>&quot;;document.newrelease.v.value=&quot;<%=v%>&quot;;document.newrelease.submit()' onMouseOver=&quot;window.status='Goto Page <%=v%>'; return true&quot; onMouseOut=&quot;window.status=''; return true&quot;><%=v%></a></b></font>
</td>
<%Else%>
<td width=&quot;16&quot; align=&quot;center&quot; valign=&quot;top&quot; align=&quot;center&quot;><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot; color=&quot;white&quot;><b><%=v%></b></font>
</td>
<%End if
Next %>

</form>


<%end if%>

</body>
</html>



Try this coding . It will help you to display 5 records per page

Bye
Omprakash
 
<%
Dim conn,db_connectionstring,sql,rs,pict,movie,movieold,flag,arr(20)
position=request.form(&quot;position&quot;)
count=request.form(&quot;count&quot;)
v=request.form(&quot;v&quot;)

if v=&quot;&quot; then
v=1
end if
if position=&quot;&quot; then
position=&quot;1&quot;
end if
if count=&quot;&quot; then
count=&quot;0&quot;
end if
set conn=server.createobject(&quot;ADODB.connection&quot;)
db_connectionstring = &quot;driver={microsoft access driver (*.mdb)}; dbq=&quot; & server.mappath(&quot;../data/general.mdb&quot;)
conn.open db_connectionstring

'var thedate = new Date(year, month, date)
set rs=server.createobject(&quot;ADODB.RECORDSET&quot;)
sql=&quot;select * from guestbook order by date desc&quot;
set rs=conn.execute(sql)%>
<!--#include file=&quot;top.inc&quot;-->
<form method=&quot;post&quot; action=&quot;gbookupdated.asp&quot;>
<table border=&quot;0&quot; align=&quot;center&quot; cellpadding=&quot;0&quot; width=&quot;500&quot; cellspacing=&quot;0&quot;>
<tr>
<td colspan=&quot;2&quot;>
<div align=&quot;center&quot;><font size=&quot;4&quot; face=&quot;Arial, Helvetica, sans-serif&quot; color=&quot;white&quot;><B>GuestBook</b></font></div>
</td>
</tr>
<tr>
<td colspan=&quot;2&quot;>&nbsp;</td>
</tr>
<tr>
<td><font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot; color=&quot;white&quot;>Name:</font></td>
<td>
<input type=&quot;text&quot; name=&quot;name&quot;>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot; color=&quot;white&quot;>Email:</font></td>
<td>
<input type=&quot;text&quot; name=&quot;email&quot;>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;2&quot; color=&quot;white&quot;>Comments:</font></td>
<td>
<textarea name=&quot;comments&quot;></textarea>
</td>
</tr> <tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan=&quot;2&quot;>
<div align=&quot;center&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Guestbook&quot;>
</div>
</td>
</tr>
</table>
</form>


<form name=&quot;newrelease&quot; method=&quot;post&quot; action=&quot;guestbook.asp&quot;><%
if not rs.eof then
totalrec=0
do while not rs.eof
rs.movenext
totalrec=totalrec+1
loop
rs.movefirst
dim temp(200)
i=0
perpage=7
totalpage=int(totalrec/perpage)

If not totalpage=(totalrec/perpage) then
totalpage=totalpage+1
End if
counter=1
x=1
Do while not rs.eof
if ((counter mod perpage)=0)then
arr(x)=counter
x=x+1

end if
counter=counter+1
rs.movenext
loop
rs.movefirst


%>
<input type=&quot;hidden&quot; name=&quot;position&quot; value=&quot;<%=position%>&quot;>
<input type=&quot;hidden&quot; name=&quot;count&quot; value=&quot;<%=count%>&quot;>
<input type=&quot;hidden&quot; name=&quot;v&quot; value=&quot;<%=v%>&quot;>

<table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;Center&quot; >

<%
ct=cint(position)
ctx=ct
if v=1 then
rs.move 0
else
rs.move arr(v-1)
end if


do while not rs.eof
if ctx < (cint(position)+perpage) then

ctx=ctx+1
name=rs(0)
email=rs(1)
Comments=rs(2)
dt=rs(3)
pos=pos+1

%>
<tr bgcolor=&quot;#FFFFCC&quot;>
<td align=&quot;left&quot;><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;2&quot; color=&quot;black&quot;><b><%=name%></b>&nbsp;&nbsp;posted it on &nbsp;<%=dt%></font></td>
</tr><BR><Tr>
<td colspan=&quot;2&quot; align=&quot;left&quot;><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;2&quot; color=&quot;white&quot;><%=Comments%></font></td>
</tr><TR><TD>&nbsp;</td></tr>
<%rs.movenext

else
exit do
end if


loop%>
</table><%
For v = 1 to totalpage

If trim(position)<>trim(cstr(v*perpage-(perpage-1))) then
%>
<td width=&quot;16&quot; align=&quot;center&quot; valign=&quot;top&quot; align=&quot;Center&quot;><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot;><b><a href='javascript:document.newrelease.position.value=<%=(v*perpage-perpage)+1%>;document.newrelease.count.value=&quot;<%=count%>&quot;;document.newrelease.v.value=&quot;<%=v%>&quot;;document.newrelease.submit()' onMouseOver=&quot;window.status='Goto Page <%=v%>'; return true&quot; onMouseOut=&quot;window.status=''; return true&quot;><%=v%></a></b></font>
</td>
<%Else%>
<td width=&quot;16&quot; align=&quot;center&quot; valign=&quot;top&quot; align=&quot;center&quot;><font face=&quot;Verdana, Arial, Helvetica, sans-serif&quot; size=&quot;2&quot; color=&quot;white&quot;><b><%=v%></b></font>
</td>
<%End if
Next %>

</form>


<%end if%>

</body>
</html>

try this codin it will display 5 records per page


Bye.
 
Anyone have something more simple where I don't have to change my entire code just for this?

Thanks
 
Please somebody help!! We now have 55 pages and it's increasing about 2 pages per day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top