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!

need help breaking asp data into pages

Status
Not open for further replies.

seanwest

Technical User
Jan 23, 2003
17
US
hi

this is a whos online script from authentix that i am using for the whos online page of my profiles site.

This script pulls the usernames from an authentix cache session or something close to that and then just shows
them all on one page.. i would like to find out how to
break it up into 20 per page and have it make the other pages as well.

anyone know how?

<!--################################################-->
<!--#INCLUDE FILE = "refresh.htm"-->
<!--#INCLUDE FILE = "incl.asp"-->
<center>

<%

Set accessname = Request.Form("accessname")
if ("" = accessname) Then
accessname = Request.QueryString("accessname")
End if


nameList = ""
llList = ""
res1 = ""
res2 = ""
res3 = ""
res4 = ""
res5 = ""
res6 = ""
res7 = ""
res8 = ""
userCount = auth.CurrentUsers(accessName, nameList, llList, res1, res2, res3, res4, res5, res6, res7, res8)

if (0 <= userCount) Then
' good
else
response.Write("&ltH2>CurrentUsers Failed with error code: ")
response.Write(userCount)
'response.Write(", meaning: ")
'response.Write(eyescope.ErrorCodeToMessage(result))
response.Write("</H2>")
response.End
End If

nameArray = Split(nameList, chr(1))
llArray = Split(llList, chr(1))
%>

*****some html then***

<%

for cNumber = 0 To UBound(nameArray)
username = nameArray(cNumber)
%>
<br>

<%while not RS.eof%>



<%=RS("user_image")%>




<%RS.MoveNext%>


<%wend%>

<%
RS.Close
MyConn.Close
%>


<%
remainder = (cNumber + 1) mod 9
if (0 = remainder) Then
%>


<%
End if

'exit for
Next
%>
 
put the info into an array

Page 1 show array[0] -> array[19]
Page 2 show array[20] -> array[39]

using uBound(array) you can even calculate how many users and then place the right number of page links at the bottom of each page.

How about some other fancy stuff like longest online, most recent etc.

Steve Davis
hey.you@hahaha.com.au

Me? I can't even spell ASP!
 
great

but is there any way to make it do the pages on its own? like make the links but they just refer to itself and it still works properly?

ill have anywhere from 100 - 400 people online at one
time and am not sure if i should just limit pages, and if i make say 20 pages, and there are enough people online for 25 pages, what would happen if anything? im not the brightest. thank you .

Sean
 
Microbe: Kinda like that nameArray variable he's using? ;)

I agree with Microbes method on this. You can pass te "record number" (starting index your going to show) as part of the querystring. If no value is passed in the querystring you can safely assume that your to show the first page. Your max page count would actually be UBound(nameArray) + 1 divided by the number of records your showing per page, rounded up. or you could use the UserCount variable that is being returned.

One other thing you will need to do is add in an escape in your for next statement that is displaying the records so that you don't get an error on your last page if you don't have enough records. Basically just add in an If UBound(nameArray) > yourIndex Then Exit For line as an escape should you have a partial page to display.

Another option you could add relatively easily would be to allow the user to choose ow many records are displayed. This value could also be passed in the querystring and you would use it in your calculations instead of a hardcoded value. The link would just pass the recordcount and a page number of 1 (or no page number at all to dedfault to 1).

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
hehe Tarwn...I didn't even look at the code...geerally when people post code here there is just TOO much of it to try to go through so I ignore it unless I can see the lot on the 1st screen.

You are pretty generous with your help. I tend to give a quick answer as a suggestion and let people work the rest out for themselves, otherwise they may keep coming back for help with the fine details.

The other thing you could do Sean is ask "how many users do you want to show" - distinct from how many per page - and with a few options like "most recent" "longest on line" "have 'z' in username" "show members only" limit the scope of the list.

Steve Davis
hey.you@hahaha.com.au

Me? I can't even spell ASP!
 
Microbe: Yeah, IU know the feeling, I have ignored posts in the past that have over a page of code (especially if they display something that says "error on line x" then don't tell me which line is line x). My general method is to read the whole post first, then go back and read the code if I need it, looking only for specifics. I sometimes miss obvious errors this way, but I will also catch things like that array without having to read all of the code.

I lke to give longer, more in depth explanations that explain some of the "how" behind things, i find that most people will be able to solve it themselves the second ytime around because the explantion explains why things work they way they do. Smaller explanations are fine also, but I hate giving diect, "here is the code" answers on the "give a man a fish and he'll eat fora day" concept.

Sean: Sorry to crap up your post space, hope that Microbe and I were able to give you all the answers (and 50 more additional features to add ;) ) between us,

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
well ya got me! i am not very smart in asp and looking for someone to show me exactly how to complete this task. I would actually like to pay someones time to do it, but i heard that also was not allowed on this site so i do not see how else to approach the matter.

The info you gave me is helpful yes, but as you already know its not enough to make it work.. you all arent setting out to frustrate dummies like me are ya :) just give us the brownie, let us stare at the milk.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top