Forum Moderators: open
I have a few problems with this.
1. The routine I use for naming just compares the first letter as a "save" letter. If it's different then it prints out a header letter.
A <--- Header letter
Abby
Anne
Azule
B <--- Header letter
Billy
Bobby
Ok the problem is some people have ' and - in their names (this is for an online game).
So it does:
B
Billy
Bobby
-
-Britanny
B
Brynn
Any help on this? Write a routine that loops through non-alphabetically characters until it reaches an alpha char and compare that?
2. Some pages have over 300 names on them now. It's too long to scroll all the way down. Anyone know a good paging tutorial using alphabetical rather than 1-2-3-4-Next type paging?
Such as setting up A-D, E-H, I-M in place of the 1-2-3-4 etc.
<center>
- <a href='?page=memberlist&letter=other'>#</a> -
<%
for x=1 to 26
response.write " <a href='?letter=" & chr(64+x) & "'>" & chr(64+x) & "</a> -"
next
%>
</center>
now heres some SQL to get you going, it checks for a Request.QueryString("letter"), if none is found it displays the last 10 people who logged in
if request.QueryString("letter") = "" then
sSQL = "SELECT TOP 10 Username,LastLogin,Email,ShowEml,clanURL,ImageURL FROM Members ORDER BY LastLogin DESC"
else
if request.QueryString("letter") = "other" then
sSQL = "SELECT Username,LastLogin,Email,ShowEml,clanURL,ImageURL " & _
"FROM Members " & _
"WHERE Username Like '[1234567890{}()$£-]%'" & _
"ORDER BY Username"
else
sSQL = "SELECT Username,LastLogin,Email,ShowEml,clanURL,ImageURL " & _
"FROM Members " & _
"WHERE Username LIKE '" & request.Querystring("letter") & "%'" & _
"ORDER BY Username"
end if
end if
you can then page the returned recordset any way you please, its returned alpabetically.
the only special characters i allow are {}()[]$£-, people whu start their name with square brackets are not listed in the mater listing - but what the hell
I just recently used this code from Asp101 : [asp101.com...]
Worked like a champ for alphabetical and numerical paging.
SELECT * FROM Members WHERE Username='A%'
the % simply implies "anything", so we get a recordset returned from the database of all users where the username is A<something> [not case sensitive]
the square brackets are used to imply the first letter
i.e.
[1234567890{}()$£-]% basically means "starts with" 123456789{}()$£- "then anything"
However the example cococure gave will be good for when (if) we need to impliment scalability to the site.
Right now it's just a hobby site used basically to get something on my resume for when I graduate and to bring in a couple extra hundred bucks a month :)