Author |
Topic |
bjlt
Senior Member
1144 Posts |
Posted - 08 May 2003 : 15:02:18
|
this one counts all, male, female, unknown e.g. GetUserCountOfCountry("USA",1) will get number of male Americans.
Function GetUserCountOfCountry(psCountry,piSex) '# 0=all individual, 1=male, 2=female, 3=unknown
Dim rs, sSQL
Dim lTemp
sSQL = "SELECT COUNT(MEMBER_ID) AS TempCount FROM " & strMemberTablePrefix & "MEMBERS WHERE M_COUNTRY = " & chkString(psCountry,"SQLString") & " AND M_STATUS = 1 "
Select Case piSex
Case 1
sSQL = sSQL & " AND M_SEX = 1 " '# M_SEX = 'male'
Case 2
sSQL = sSQL & " AND M_SEX = 2 " '# M_SEX = 'female'
Case 3
sSQL = sSQL & " AND M_SEX <> 1 AND M_SEX <> 2 " '# M_SEX <> 'female' AND M_SEX <> 'male'
Case Else
'
End Select
Set rs = my_Conn.Execute(sSQL)
lTemp = Clng(rs("TempCount"))
rs.close
set rs = nothing
GetUserCountOfCountry = lTemp
End Function
|
Edited by - bjlt on 10 May 2003 01:43:22 |
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 09 May 2003 : 16:24:18
|
Woah! Cool
I tried them out though, it seems to have trouble with MEMBERS_NEW
I forgot what the error message is, because it's on another machine, but I'll post it here soon!
Thanks again mate! |
|
|
bjlt
Senior Member
1144 Posts |
Posted - 10 May 2003 : 01:36:13
|
it should be MEMBERS btw, if you want to add more fields to show but don't know how, just name them here. |
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 10 May 2003 : 05:34:00
|
I get this error on the first code you gave me...
Microsoft VBScript runtime error '800a0009' Subscript out of range: 'mM_RECEIVE_EMAIL'
/where2.asp, line 108
So I commented it out and it works
What I'd like to do though, is have this info on the page (in a table like members.asp)...
A column for MSN, Yahoo, PM etc A column for Gender (using the Male/Female icon) A column for Username A column for Name A colomn for City
If you could point me in the right direction for one of those, then I'll try and figure out the rest
Thanks for all your help |
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 10 May 2003 : 05:44:51
|
Also, the classes which it uses...I take it I can change these ok, as they're pointing to classes used by you!? I didn't want to change them if they need to be there.
One other thing I found, is the drop down list for the page numbers etc...if I choose from the dropdown list, it gives me an error, but using the next/previous page links work
Cheers mate! |
|
|
bjlt
Senior Member
1144 Posts |
Posted - 10 May 2003 : 07:21:15
|
classes are for html design so you don't need it there, it's from my original codes which is not for snitz, change it to what ever you want. fyi as long as it's html you can change it.
I can code you MSN, Yahoo, PM in the contact column and then show you how to add other fields, but I'm not available right now, maybe in a day or two.
I'll also take a look at the dropdown paging when I have time, what's the error? is it javascript related? |
|
|
bjlt
Senior Member
1144 Posts |
Posted - 10 May 2003 : 07:23:19
|
oh, please remove mM_NATIONALITY = 5 but not mM_RECEIVE_EMAIL = 7, see the original codes above for the change.
you can see that the number equals to it's position in the sql statement from 0. if you add more fields, just add them to the sql statement, and the mXXXX = and XXXX = parts and then you can retrieve XXXX to show in your page.
for links to icq, pm, email msn etc you can refer to the codes where they are used and put them in the html part. e.g. contact column for pm, icq, msn, email, homepage.
|
Edited by - bjlt on 10 May 2003 07:29:18 |
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 10 May 2003 : 12:26:23
|
Cheers mate!
The drop down error just says 'Error on page' in the status bar of IE...not sure what it is...sorry |
|
|
bjlt
Senior Member
1144 Posts |
Posted - 10 May 2003 : 15:01:52
|
ok, it's a javascript error then as u don't have it.
put the code below in somewhere in <header></header> or <body></body>
<script language="JavaScript" type="text/javascript">
function ChangePage(fnum){
if (fnum == 1) {
document.PageNum1.submit();
}
else {
document.PageNum2.submit();
}
}
</script>
|
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 11 May 2003 : 03:53:01
|
Works great
Cheers [:D)] |
|
|
bjlt
Senior Member
1144 Posts |
Posted - 11 May 2003 : 07:46:49
|
new code, please read comments in it. feature not implemented: sorting sql codes are there, just no links provided, check for other pages with sorting to see how to add it, basically u do two things 1. add link to th e.g. <a href=""filename.asp?countryid=" & iCountryID & "&method=" & iMethod & "&sort=" if sSortMethod = usernamedesc then Response.Write "usernameasc" & """>" & sIconSortDesc else Response.Write "locationdesc" & """>" & sIconSortAsce end if Response.Write & username & "</a>
2. add sort= in dropdown previous/next link e.g. "
<a href=""filename.asp?countryid=" & iCountryID & "&method=" & iMethod & "&sort=" & sSortMethod & "&whichpage=" & iWhichPage - 1 & """>" & prevous page & "</a>" & vbNewLine
have fun
<%
'your header and includes here
'####### Global Variables #######
Dim sCountry, iMethod
Dim iPagesize
Dim iWhichPage, iTotalPages
Dim sSortMethod
Dim sIconMale, sIconFemale, sIconUnknown
sCountry = Trim(Request("country"))
iMethod = Clng(Request("method"))
if iMethod < 0 or iMethod > 3 then iMethod = 0
iPagesize = clng(strPageSize)
sSortMethod = Trim(Request("sort"))
sIconMale = getCurrentIcon(strIconMale,"Male","hspace=""4"" align=""absmiddle""")
sIconFemale = getCurrentIcon(strIconFemale,"Female","hspace=""4"" align=""absmiddle""")
sIconUnknown = "" '# your icon here
'######## Start Content #########
if sCountry = "" then Response.Redirect "MemberCountByCountry.asp" : Response.End '# MemberCountByCountry.asp is a file I use to list num of users for every country. change it to the page you like.
DoListUsersByCountry
'######### End Content ##########
WriteFooter
'####### Procedures Below #######
Sub DoListUsersByCountry()
Dim sSQL, sSQLO, rs
Dim sModFields
Dim aListByCountry, iRecCount
Dim i, j
Dim mMEMBER_ID, mM_NAME, mM_FIRSTNAME, mM_LASTNAME, mM_LEVEL, mM_TITLE, mM_EMAIL, mM_RECEIVE_EMAIL, mM_HOMEPAGE, mM_ICQ, mM_MSN, mM_AIM, mM_YAHOO, mM_COUNTRY, mM_STATE, mM_CITY, mM_SEX, mM_PMRECEIVE
Dim MEMBER_ID, M_NAME, M_FIRSTNAME, M_LASTNAME, M_LEVEL, M_TITLE, M_EMAIL, M_RECEIVE_EMAIL, M_HOMEPAGE, M_ICQ, M_MSN, M_AIM, M_YAHOO, M_COUNTRY, M_STATE, M_CITY, M_SEX, M_PMRECEIVE
Dim sClass
Dim sIconSortAsc, sIconSortDesc, sEmptyIcon
Dim bShowContact
sIconSortAsc = getCurrentIcon(strIconSortASC,"Click to sort by Descending","hspace=""4"" align=""absmiddle""")
sIconSortDesc = getCurrentIcon(strIconSortDESC,"Click to sort by Ascending","hspace=""4"" align=""absmiddle""")
sEmptyIcon = "" '# your blank icon here of same dimention of homepage,email etc
iWhichPage = GetPageNum(Trim(Request("whichpage")))
sModFields = ""
if mLev > 2 or strEmail = "1" or strHomepage = "1" or strAIM = "1" or strICQ = "1" or strMSN = "1" or strYAHOO = "1" or gbPM then
bShowContact = true
end if
If gbPM then '# I don't have pm mod, look up the variable it used to turn on/off PM, make sure to change all instances of it in this page. or if you use it, add const gbPM = true at the Global Variables part
sModFields = ", M.M_PMRECEIVE "
end if
'## get user list by country/nationality
sSQL = "SELECT M.MEMBER_ID, M.M_NAME, M_FIRSTNAME, M_LASTNAME, M.M_LEVEL, M.M_TITLE, M.M_EMAIL, M.M_RECEIVE_EMAIL, M.M_HOMEPAGE, M.M_ICQ, M.M_MSN, M.M_AIM, M.M_YAHOO, M.M_COUNTRY, M.M_STATE, M.M_CITY, M.M_SEX" & sModFields & " FROM " & strMemberTablePrefix & "MEMBERS M WHERE M.M_STATUS = 1 AND M.M_COUNTRY = '" & chkString(sCountry,"SQLString") & "'"
Select Case iMethod '# I use 0/1/2/3 for sex if you use male/female/etc change it accrodingly below
Case 1
sSQL = sSQL & " AND M.M_SEX = 1" '# = 'male'
Case 2
sSQL = sSQL & " AND M.M_SEX = 2" '# = 'female'
Case 3
sSQL = sSQL & " AND M.M_SEX <> 1 AND M.M_SEX <> 2" '# M.M_SEX <> 'male' AND M.M_SEX <> 'female'
Case Else
'
End Select
select case sSortMethod
case "usernameasc"
sSQLO = " ORDER BY M.M_NAME ASC"
case "usernamedesc"
sSQLO = " ORDER BY M.M_NAME DESC"
case "lastnameasc"
sSQLO = " ORDER BY M.M_LASTNAME ASC, M.M_FIRSTNAME ASC"
case "lastnamedesc"
sSQLO = " ORDER BY M.M_LASTNAME DESC, M.M_FIRSTNAME DESC"
case "locasc"
sSQLO = " ORDER BY M.M_STATE ASC, M.M_CITY ASC"
case "locdesc"
sSQLO = " ORDER BY M.M_STATE DESC, M.M_CITY DESC"
case "sexasc"
sSQLO = " ORDER BY M.M_SEX ASC"
case "sexdesc"
sSQLO = " ORDER BY M.M_SEX DESC"
case else
sSQLO = " ORDER BY M.M_NAME ASC"
end select
Set rs = Server.CreateObject("ADODB.Recordset")
rs.cachesize = iPagesize
rs.open sSQL & sSQLO, my_Conn, adOpenStatic, adLockReadOnly, adCmdText
if rs.EOF or rs.BOF then '## No Users found
iRecCount = 0
Else
rs.pagesize = iPagesize
iTotalPages = cLng(rs.pagecount)
if iWhichPage > iTotalPages then iWhichPage = iTotalPages
rs.absolutepage = iWhichPage
aListByCountry = rs.GetRows(iPagesize)
iRecCount = UBound(aListByCountry,2) + 1
End If
rs.close
set rs = nothing
Response.Write "" &_
"<table border=0 width=""100%"" cellpadding=""0"" cellspacing=""0"" align=""center"">" & vbNewLine & _
" <tr>" & vbNewLine
Call DropDownPaging(1)
Response.Write "" &_
" </tr>" & vbNewLine & _
"</table>" & vbNewLine &_
"<table align=""center"" class=""TblList"">" & vbNewLine & _
" <tr>" & vbNewLine
if bShowContact then
Response.Write "" &_
" <th class=""TblHeadCellDefault"">Contact</th>" & vbNewLine
end if
Response.Write "" &_
" <th class=""TblHeadCellDefault"">Username</th>" & vbNewLine
" <th class=""TblHeadCellDefault"">Name</th>" & vbNewLine
if strSex = "1" then
Response.Write "" &_
" <th class=""TblHeadCellDefault"">Sex</th>" & vbNewLine
end if
if strCity = "1" or strState = "1" then
Response.Write "" &_
" <th class=""TblHeadCellDefault"">Location</th>" & vbNewLine
end if
Response.Write "" &_
" </tr>" & vbNewLine
If iRecCount = 0 Then
Call WriteNoRecCells(5) '# how many colomns you have
Else
mMEMBER_ID = 0
mM_NAME = 1
M_FIRSTNAME = 2
M_LASTNAME = 3
mM_LEVEL = 4
mM_TITLE = 5
mM_EMAIL = 6
mM_RECEIVE_EMAIL = 7
mM_HOMEPAGE = 8
mM_ICQ = 9
mM_MSN = 10
mM_AIM = 11
mM_YAHOO = 12
mM_COUNTRY = 13
mM_STATE = 14
mM_CITY = 15
mM_SEX = 16
if gbPM then '##
mM_PMRECEIVE = 17
end if
i = 0
j = 0
For i = 0 to iRecCount - 1
MEMBER_ID = aListByCountry(mMEMBER_ID,i)
M_NAME = aListByCountry(mM_NAME,i)
M_FIRSTNAME = aListByCountry(mM_FIRSTNAME,i)
M_LASTNAME = aListByCountry(mM_LASTNAME,i)
M_LEVEL = aListByCountry(mM_LEVEL,i)
M_TITLE = aListByCountry(mM_TITLE,i)
M_EMAIL = aListByCountry(mM_EMAIL,i)
M_RECEIVE_EMAIL = aListByCountry(mM_RECEIVE_EMAIL,i)
M_HOMEPAGE = aListByCountry(mM_HOMEPAGE,i)
M_ICQ = aListByCountry(mM_ICQ,i)
M_MSN = aListByCountry(mM_MSN,i)
M_AIM = aListByCountry(mM_AIM,i)
M_YAHOO = aListByCountry(mM_YAHOO,i)
M_COUNTRY = aListByCountry(mM_COUNTRY,i)
M_STATE = aListByCountry(mM_STATE,i)
M_CITY = aListByCountry(mM_CITY,i)
M_SEX = aListByCountry(mM_SEX,i)
if gbPM then '##
M_PMRECEIVE = aListByCountry(mM_PMRECEIVE,i)
end if
if j = 0 then
sClass = "TblCellDefault" '## change it to what u want
else
sClass = "TblAltCellDefault" '## change it to what u want
end if
Response.Write "" &_
" <tr>" & vbNewLine
if bShowContact then
Response.Write "" &_
" <td align=""left"" class=""" & sClass & """>"
'# contact links code from topic.asp, customized
if strEmail = "1" and (mLev > 2 or M_RECEIVE_EMAIL = "1") then
if (mlev <> 0) or (mlev = 0 and strLogonForMail <> "1") then
Response.Write "?lt;a href=""javascript:openWindow('pop_mail.asp?id=" & MEMBER_ID & "')"">" & getCurrentIcon(strIconEmail,"Send " & ChkString(M_NAME,"display") & " an Email message","align=""absmiddle"" hspace=""6""") & "</a>"
end if
end if
if strHomepage = "1" then
if M_HOMEPAGE <> " " then
Response.Write "?lt;a href=""" & M_HOMEPAGE & """ target=""_blank"">" & getCurrentIcon(strIconHomepage,"Visit " & ChkString(M_NAME,"display") & "'s Homepage","align=""absmiddle"" hspace=""6""") & "</a>"
else
Response.Write sEmptyIcon
end if
end if
if (strAIM = "1") then
if Trim(M_AIM) <> "" then
Response.Write "?lt;a href=""javascript:openWindow('pop_messengers.asp?mode=AIM&ID=" & MEMBER_ID & "')"">" & getCurrentIcon(strIconAIM,"Send " & ChkString(M_NAME,"display") & " an AOL message","align=""absmiddle"" hspace=""6""") & "</a>"
else
Response.Write sEmptyIcon
end if
end if
if strICQ = "1" then
if Trim(M_ICQ) <> "" then
Response.Write "?lt;a href=""javascript:openWindow('pop_messengers.asp?mode=ICQ&ID=" & MEMBER_ID & "')"">" & getCurrentIcon(strIconICQ,"Send " & ChkString(M_NAME,"display") & " an ICQ Message","align=""absmiddle"" hspace=""6""") & "</a>"
else
Response.Write sEmptyIcon
end if
end if
if (strMSN = "1") then
if Trim(M_MSN) <> "" then
Response.Write "?lt;a href=""javascript:openWindow('pop_messengers.asp?mode=MSN&ID=" & MEMBER_ID & "')"">" & getCurrentIcon(strIconMSNM,"Click to see " & ChkString(M_NAME,"display") & "'s MSN Messenger address","align=""absmiddle"" hspace=""6""") & "</a>"
else
Response.Write sEmptyIcon
end if
end if
if strYAHOO = "1" then
if Trim(M_YAHOO) <> "" then
Response.Write "?lt;a href=""http://edit.yahoo.com/config/send_webmesg?.target=" & ChkString(M_YAHOO, "urlpath") & "&.src=pg"" target=""_blank"">" & getCurrentIcon(strIconYahoo,"Send " & ChkString(M_NAME,"display") & " a Yahoo! Message","align=""absmiddle"" hspace=""6""") & "</a>"
else
Response.Write sEmptyIcon
end if
end if
if gbPM then '##
if M_PMRECEIVE = 1 then
'# I don't have pm mod, put the code here urself pls.
end if
end if
'# end code from topic.asp
Response.Write "" &_
"</td>" & vbNewLine
end if
Response.Write "" &_
" <td align=""center"" class=""" & sClass & """><a href=""pop_profile.asp?mode=display&id=" & MEMBER_ID & """ target=""profile"">" & ChkString(M_NAME,"display") & "</a></td>" & vbNewLine &_
" <td align=""center"" class=""" & sClass & """>" & chkString(GetName(M_FIRSTNAME,M_LASTNAME),"display") & "</td>" & vbNewLine
if strSex = "1" then
Response.Write "" &_
" <td align=""center"" class=""" & sClass & """>" & GetSexIcon(M_SEX) & "</td>" & vbNewLine
end if
if strCity = "1" or strState = "1" then
Response.Write "" &_
" <td align=""center"" class=""" & sClass & """>" & GetLocation(M_STATE,M_CITY) & "</td>" & vbNewLine
end if
Response.Write "" &_
" </tr>" & vbNewLine
j = j + 1
if j = 2 then j = 0
Next
End if
Response.Write "" &_
"</table>" & vbNewLine &_
"<table border=0 width=""100%"" cellpadding=""0"" cellspacing=""0"">" & vbNewLine & _
" <tr>" & vbNewLine
Call DropDownPaging(2)
Response.Write "" &_
" </tr>" & vbNewLine & _
"</table>" & vbNewLine
%>
<script language="JavaScript" type="text/javascript">
function ChangePage(fnum){
if (fnum == 1) {
document.PageNum1.submit();
}
else {
document.PageNum2.submit();
}
}
</script>
<%
End Sub
sub DropDownPaging(piNum)
Dim sAlign, i
if piNum mod 2 = 0 then
sAlign = "left"
Else
sAlign = "right"
End If
if iTotalPages > 1 then
Response.Write "" &_
"<form name=""PageNum" & piNum & """ action=""ListUsersByCountry.asp"">" & vbNewLine &_
" <input name=""method"" type=""hidden"" value=""" & iMethod & """>" & vbNewLine &_
" <input name=""country"" type=""hidden"" value=""" & sCountry & """>" & vbNewLine &_
" <input name=""sort"" type=""hidden"" value=""" & sSortMethod & """>" & vbNewLine &_
" <td align=""" & sAlign & """>" & vbNewLine
if iWhichPage > 1 then
Response.Write "" &_
" <a href=""ListUsersByCountry.asp?country=" & ChkString(sCountry,"urlpath") & "&method=" & iMethod & "&whichpage=" & iWhichPage - 1 & """>Previous Page</a>" & vbNewLine
end if
Response.Write "<b>Page</b>" & vbNewLine &_
" <select name=""whichpage"" size=""1"" onchange=""ChangePage(" & piNum & ");"">" & vbNewLine
for i = 1 to iTotalPages
Response.Write "" &_
" <option value=""" & i & """"
if i = iWhichPage then response.write "selected"
response.write "" &_
">" & i & "</option>" & vbNewLine
next
Response.Write "" &_
" </select>" & vbNewLine &_
" <b>Total: " & iTotalPages & "</b>? & vbNewLine
if iWhichPage < iTotalPages then
Response.Write "" &_
" <a href=""ListUsersByCountry.asp?country=" & ChkString(sCountry,"urlpath") & "&method=" & iMethod & "&whichpage=" & iWhichPage + 1 & """>Next Page</a>" & vbNewLine
end if
Response.Write "" &_
" </td>" & vbNewLine &_
"</form>" & vbNewLine
else
Response.Write "<td>?lt;/td>"
end if
end sub
Sub WriteNoRecCells(colspan)
Response.Write "" &_
" <tr>" & vbNewLine & _
" <td class=""TblCellDefault"" colspan=""" & colspan & """ align=""center""> No Members </td>" & vbNewLine &_
" </tr>" & vbNewLine
End Sub
Function GetPageNum(piPage)
if piPage = "" or not isnumeric(piPage) then
GetPageNum = 1
else
GetPageNum = Clng(piPage)
if GetPageNum < 1 then GetPageNum = 1
end if
End Function
Function GetSexIcon(piSex)
Select Case piSex
Case 1 '# "male"
GetSexIcon = sIconMale
Case 2 '# "female"
GetSexIcon = sIconFemale
Case Else
GetSexIcon = sIconUnknown
End Select
End Function
Function GetLocation(psState,psCity)
GetLocation = ""
if strState = "1" and psState <> " " then
GetLocation = psState
end if
if strCity = "1" and psCity <> " " then
if GetLocation <> "" then
GetLocation = GetLocation & ", " & psCity
else
GetLocation = psCity
end if
end if
End Function
Function GetName(psFirst,psLast)
GetName = ""
if psFirst <> " " then GetName = psFirst
if psLast <> " " then
if GetName = "" then
GetName = psLast
else
GetName = GetName & ", " & psLast
end if
end if
End Function
%>
edit: minor change: from M.M_CITY DESC to M.M_CITY ASC bug fix: there should be no peremeters in DoListUsersByCountry() bug fix: changed ChkString(M_FIRSTNAME & ", " & M_LASTNAME,"display") to chkString(GetName(M_FIRSTNAME,M_LASTNAME),"display")
|
Edited by - bjlt on 11 May 2003 11:59:14 |
|
|
mortioli
Average Member
United Kingdom
898 Posts |
Posted - 11 May 2003 : 10:01:35
|
Cheers! Erm, I actually change the code you give me, to be used for the STATE field instead of COUNTRY (because it's a UK site - so 99% of users are from the UK), and have been ok up till now, and now I have trouble
This is the above code, changed to STATE etc...
<!--#INCLUDE virtual="forum/config.asp" --> <!--#INCLUDE virtual="forum/inc_sha256.asp" --> <!--#INCLUDE virtual="forum/inc_header_short.asp" --> <!--#INCLUDE virtual="forum/inc_func_member.asp" -->
<% '####### Global Variables ####### Dim sstate, iMethod Dim iPagesize Dim iWhichPage, iTotalPages Dim sSortMethod Dim sIconMale, sIconFemale, sIconUnknown
sstate = Trim(Request("state")) iMethod = Clng(Request("method")) if iMethod < 0 or iMethod > 3 then iMethod = 0
iPagesize = clng(strPageSize) sSortMethod = Trim(Request("sort"))
sIconMale = getCurrentIcon(strIconMale,"Male","hspace=""4"" align=""absmiddle""") sIconFemale = getCurrentIcon(strIconFemale,"Female","hspace=""4"" align=""absmiddle""") sIconUnknown = "" '# your icon here
'######## Start Content #########
if sstate = "" then Response.Redirect "where.asp" : Response.End '# MemberCountBystate.asp is a file I use to list num of users for every state. change it to the page you like.
DoListUsersByState
'####### Procedures Below ####### Sub DoListUsersByState(pbPM,pbState,pbCity,pb) Dim sSQL, sSQLO, rs Dim sModFields Dim aListBystate, iRecCount Dim i, j Dim mMEMBER_ID, mM_NAME, mM_FIRSTNAME, mM_LASTNAME, mM_LEVEL, mM_TITLE, mM_EMAIL, mM_RECEIVE_EMAIL, mM_HOMEPAGE, mM_ICQ, mM_MSN, mM_AIM, mM_YAHOO, mM_STATE, mM_CITY, mM_SEX, mM_PMRECEIVE
Dim MEMBER_ID, M_NAME, M_FIRSTNAME, M_LASTNAME, M_LEVEL, M_TITLE, M_EMAIL, M_RECEIVE_EMAIL, M_HOMEPAGE, M_ICQ, M_MSN, M_AIM, M_YAHOO, M_STATE, M_CITY, M_SEX, M_PMRECEIVE Dim sClass Dim sIconSortAsc, sIconSortDesc, sEmptyIcon Dim bShowContact
sIconSortAsc = getCurrentIcon(strIconSortASC,"Click to sort by Descending","hspace=""4"" align=""absmiddle""") sIconSortDesc = getCurrentIcon(strIconSortDESC,"Click to sort by Ascending","hspace=""4"" align=""absmiddle""") sEmptyIcon = "" '# your blank icon here of same dimention of homepage,email etc
iWhichPage = GetPageNum(Trim(Request("whichpage")))
sModFields = ""
if mLev > 2 or strEmail = "1" or strHomepage = "1" or strAIM = "1" or strICQ = "1" or strMSN = "1" or strYAHOO = "1" or gbPM then bShowContact = true end if
If gbPM then '# I don't have pm mod, look up the variable it used to turn on/off PM, make sure to change all instances of it in this page. or if you use it, add const gbPM = true at the Global Variables part sModFields = ", M.M_PMRECEIVE " end if '## get user list by state/nationality sSQL = "SELECT M.MEMBER_ID, M.M_NAME, M_FIRSTNAME, M_LASTNAME, M.M_LEVEL, M.M_TITLE, M.M_EMAIL, M.M_RECEIVE_EMAIL, M.M_HOMEPAGE, M.M_ICQ, M.M_MSN, M.M_AIM, M.M_YAHOO, M.M_CITY, M.M_SEX" & sModFields & " FROM " & strMemberTablePrefix & "MEMBERS M WHERE M.M_STATUS = 1 AND M.M_STATE = '" & chkString(sState,"SQLString") & "'"
Select Case iMethod '# I use 0/1/2/3 for sex if you use male/female/etc change it accrodingly below Case 1 sSQL = sSQL & " AND M.M_SEX = 1" '# = 'male' Case 2 sSQL = sSQL & " AND M.M_SEX = 2" '# = 'female' Case 3 sSQL = sSQL & " AND M.M_SEX <> 1 AND M.M_SEX <> 2" '# M.M_SEX <> 'male' AND M.M_SEX <> 'female' Case Else ' End Select
select case sSortMethod case "usernameasc" sSQLO = " ORDER BY M.M_NAME ASC" case "usernamedesc" sSQLO = " ORDER BY M.M_NAME DESC" case "lastnameasc" sSQLO = " ORDER BY M.M_LASTNAME ASC, M.M_FIRSTNAME ASC" case "lastnamedesc" sSQLO = " ORDER BY M.M_LASTNAME DESC, M.M_FIRSTNAME DESC" case "locasc" sSQLO = " ORDER BY M.M_STATE ASC, M.M_CITY DESC" case "locdesc" sSQLO = " ORDER BY M.M_STATE DESC, M.M_CITY DESC" case "sexasc" sSQLO = " ORDER BY M.M_SEX ASC" case "sexdesc" sSQLO = " ORDER BY M.M_SEX DESC" case else sSQLO = " ORDER BY M.M_NAME ASC" end select
Set rs = Server.CreateObject("ADODB.Recordset") rs.cachesize = iPagesize
rs.open sSQL & sSQLO, my_Conn, adOpenStatic, adLockReadOnly, adCmdText
if rs.EOF or rs.BOF then '## No Users found iRecCount = 0 Else rs.pagesize = iPagesize iTotalPages = cLng(rs.pagecount) if iWhichPage > iTotalPages then iWhichPage = iTotalPages rs.absolutepage = iWhichPage aListBystate = rs.GetRows(iPagesize) iRecCount = UBound(aListBystate,2) + 1 End If
rs.close set rs = nothing
Response.Write "" &_ "<table border=0 width=""100%"" cellpadding=""0"" cellspacing=""0"" align=""center"">" & vbNewLine & _ " <tr>" & vbNewLine Call DropDownPaging(1) Response.Write "" &_ " </tr>" & vbNewLine & _ "</table>" & vbNewLine &_ "<table align=""center"" class=""TblList"">" & vbNewLine & _ " <tr>" & vbNewLine if bShowContact then Response.Write "" &_ " <th class=""TblHeadCellDefault"">Contact</th>" & vbNewLine end if Response.Write "" &_ " <th class=""TblHeadCellDefault"">Username</th>" & vbNewLine & _ " <th class=""TblHeadCellDefault"">Name</th>" & vbNewLine if strSex = "1" then Response.Write "" &_ " <th class=""TblHeadCellDefault"">Sex</th>" & vbNewLine end if if strCity = "1" or strState = "1" then Response.Write "" &_ " <th class=""TblHeadCellDefault"">Location</th>" & vbNewLine end if Response.Write "" &_ " </tr>" & vbNewLine
If iRecCount = 0 Then Call WriteNoRecCells(5) '# how many colomns you have Else
mMEMBER_ID = 0 mM_NAME = 1 M_FIRSTNAME = 2 M_LASTNAME = 3 mM_LEVEL = 4 mM_TITLE = 5 mM_EMAIL = 6 mM_RECEIVE_EMAIL = 7 mM_HOMEPAGE = 8 mM_ICQ = 9 mM_MSN = 10 mM_AIM = 11 mM_YAHOO = 12 mM_STATE = 13 mM_CITY = 14 mM_SEX = 15 if gbPM then '## mM_PMRECEIVE = 16 end if
i = 0 j = 0
For i = 0 to iRecCount - 1 MEMBER_ID = aListBystate(mMEMBER_ID,i) M_NAME = aListBystate(mM_NAME,i) M_FIRSTNAME = aListBystate(mM_FIRSTNAME,i) M_LASTNAME = aListBystate(mM_LASTNAME,i) M_LEVEL = aListBystate(mM_LEVEL,i) M_TITLE = aListBystate(mM_TITLE,i) M_EMAIL = aListBystate(mM_EMAIL,i) M_RECEIVE_EMAIL = aListBystate(mM_RECEIVE_EMAIL,i) M_HOMEPAGE = aListBystate(mM_HOMEPAGE,i) M_ICQ = aListBystate(mM_ICQ,i) M_MSN = aListBystate(mM_MSN,i) M_AIM = aListBystate(mM_AIM,i) M_YAHOO = aListBystate(mM_YAHOO,i) M_STATE = aListByState(mM_STATE,i) M_CITY = aListBystate(mM_CITY,i) M_SEX = aListBystate(mM_SEX,i) if gbPM then '## M_PMRECEIVE = aListBystate(mM_PMRECEIVE,i) end if
if j = 0 then sClass = "TblCellDefault" '## change it to what u want else sClass = "TblAltCellDefault" '## change it to what u want end if
Response.Write "" &_ " <tr>" & vbNewLine if bShowContact then Response.Write "" &_ " <td align=""left"" class=""" & sClass & """>" '# contact links code from topic.asp, customized if strEmail = "1" and (mLev > 2 or M_RECEIVE_EMAIL = "1") then if (mlev <> 0) or (mlev = 0 and strLogonForMail <> "1") then Response.Write "?lt;a href=""javascript:openWindow('forum/pop_mail.asp?id=" & MEMBER_ID & "')"">" & getCurrentIcon(strIconEmail,"Send " & ChkString(M_NAME,"display") & " an Email message","align=""absmiddle"" hspace=""6""") & "</a>" end if end if if strHomepage = "1" then if M_HOMEPAGE <> " " then Response.Write "?lt;a href=""" & M_HOMEPAGE & """ target=""_blank"">" & getCurrentIcon(strIconHomepage,"Visit " & ChkString(M_NAME,"display") & "'s Homepage","align=""absmiddle"" hspace=""6""") & "</a>" else Response.Write sEmptyIcon end if end if if (strAIM = "1") then if Trim(M_AIM) <> "" then Response.Write "?lt;a href=""javascript:openWindow('forum/pop_messengers.asp?mode=AIM&ID=" & MEMBER_ID & "')"">" & getCurrentIcon(strIconAIM,"Send " & ChkString(M_NAME,"display") & " an AOL message","align=""absmiddle"" hspace=""6""") & "</a>" else Response.Write sEmptyIcon end if end if if strICQ = "1" then if Trim(M_ICQ) <> "" then Response.Write "?lt;a href=""javascript:openWindow('forum/pop_messengers.asp?mode=ICQ&ID=" & MEMBER_ID & "')"">" & getCurrentIcon(strIconICQ,"Send " & ChkString(M_NAME,"display") & " an ICQ Message","align=""absmiddle"" hspace=""6""") & "</a>" else Response.Write sEmptyIcon end if end if if (strMSN = "1") then if Trim(M_MSN) <> "" then Response.Write "?lt;a href=""javascript:openWindow('forum/pop_messengers.asp?mode=MSN&ID=" & MEMBER_ID & "')"">" & getCurrentIcon(strIconMSNM,"Click to see " & ChkString(M_NAME,"display") & "'s MSN Messenger address","align=""absmiddle"" hspace=""6""") & "</a>" else Response.Write sEmptyIcon end if end if if strYAHOO = "1" then if Trim(M_YAHOO) <> "" then Response.Write "?lt;a href=""http://edit.yahoo.com/config/send_webmesg?.target=" & ChkString(M_YAHOO, "urlpath") & "&.src=pg"" target=""_blank"">" & getCurrentIcon(strIconYahoo,"Send " & ChkString(M_NAME,"display") & " a Yahoo! Message","align=""absmiddle"" hspace=""6""") & "</a>" else Response.Write sEmptyIcon end if end if if gbPM then '## if M_PMRECEIVE = 1 then '# I don't have pm mod, put the code here urself pls. end if end if
'# end code from topic.asp Response.Write "" &_ "</td>" & vbNewLine end if Response.Write "" &_ " <td align=""center"" class=""" & sClass & """><a href=""forum/pop_profile.asp?mode=display&id=" & MEMBER_ID & """ target=""profile"">" & ChkString(M_NAME,"display") & "</a></td>" & vbNewLine &_ " <td align=""center"" class=""" & sClass & """>" & ChkString(M_FIRSTNAME & ", " & M_LASTNAME,"display") & "</td>" & vbNewLine if strSex = "1" then Response.Write "" &_ " <td align=""center"" class=""" & sClass & """>" & GetSexIcon(M_SEX) & "</td>" & vbNewLine end if if strCity = "1" or strState = "1" then Response.Write "" &_ " <td align=""center"" class=""" & sClass & """>" & GetLocation(M_STATE,M_CITY) & "</td>" & vbNewLine end if Response.Write "" &_ " </tr>" & vbNewLine
j = j + 1 if j = 2 then j = 0 Next End if
Response.Write "" &_ "</table>" & vbNewLine &_ "<table border=0 width=""100%"" cellpadding=""0"" cellspacing=""0"">" & vbNewLine & _ " <tr>" & vbNewLine Call DropDownPaging(2) Response.Write "" &_ " </tr>" & vbNewLine & _ "</table>" & vbNewLine %> <script language="JavaScript" type="text/javascript"> function ChangePage(fnum){ if (fnum == 1) { document.PageNum1.submit(); } else { document.PageNum2.submit(); } } </script> <% End Sub
sub DropDownPaging(piNum) Dim sAlign, i if piNum mod 2 = 0 then sAlign = "left" Else sAlign = "right" End If
if iTotalPages > 1 then Response.Write "" &_ "<form name=""PageNum" & piNum & """ action=""where2.asp"">" & vbNewLine &_ " <input name=""method"" type=""hidden"" value=""" & iMethod & """>" & vbNewLine &_ " <input name=""state"" type=""hidden"" value=""" & sstate & """>" & vbNewLine &_ " <input name=""sort"" type=""hidden"" value=""" & sSortMethod & """>" & vbNewLine &_ " <td align=""" & sAlign & """>" & vbNewLine if iWhichPage > 1 then Response.Write "" &_ " <a href=""where2.asp?state=" & ChkString(sstate,"urlpath") & "&method=" & iMethod & "&whichpage=" & iWhichPage - 1 & """>Previous Page</a>" & vbNewLine end if Response.Write "<b>Page</b>" & vbNewLine &_ " <select name=""whichpage"" size=""1"" onchange=""ChangePage(" & piNum & ");"">" & vbNewLine for i = 1 to iTotalPages Response.Write "" &_ " <option value=""" & i & """" if i = iWhichPage then response.write "selected" response.write "" &_ ">" & i & "</option>" & vbNewLine next Response.Write "" &_ " </select>" & vbNewLine &_ " <b>Total: " & iTotalPages & "</b>" & vbNewLine if iWhichPage < iTotalPages then Response.Write "" &_ " <a href=""where2.asp?state=" & ChkString(sstate,"urlpath") & "&method=" & iMethod & "&whichpage=" & iWhichPage + 1 & """>Next Page</a>" & vbNewLine end if Response.Write "" &_ " </td>" & vbNewLine &_ "</form>" & vbNewLine else Response.Write "<td>?lt;/td>" end if end sub
Sub WriteNoRecCells(colspan) Response.Write "" &_ " <tr>" & vbNewLine & _ " <td class=""TblCellDefault"" colspan=""" & colspan & """ align=""center""> No Members </td>" & vbNewLine &_ " </tr>" & vbNewLine End Sub
Function GetPageNum(piPage) if piPage = "" or not isnumeric(piPage) then GetPageNum = 1 else GetPageNum = Clng(piPage) if GetPageNum < 1 then GetPageNum = 1 end if End Function
Function GetSexIcon(piSex) Select Case piSex Case 1 '# "male" GetSexIcon = sIconMale Case 2 '# "female" GetSexIcon = sIconFemale Case Else GetSexIcon = sIconUnknown End Select End Function
Function GetLocation(psState,psCity) GetLocation = "" if strState = "1" and psState <> " " then GetLocation = psState end if if strCity = "1" and psCity <> " " then if GetLocation <> "" then GetLocation = GetLocation & ", " & psCity else GetLocation = psCity end if end if End Function
Function GetName(psFirst,psLast) GetName = "" if psFirst <> " " then GetName = psFirst if psLast <> " " then if GetName = "" then GetName = psLast else GetName = GetName & ", " & psLast end if end if End Function %>
And I use this to link to the page etc...
<a href=where2.asp?state=Hampshire&method=0 target=_blank>Hampshire: <font color=red><b>" & getStateCount("Hampshire") & "</a>
But now, using the above code, I get this error...
Microsoft VBScript runtime error '800a01c2'
Wrong number of arguments or invalid property assignment: 'DoListUsersByState'
/where2.asp, line 29
Line 29 is...
DoListUsersByState
Any ideas
I can't tell you how much I appreciate your help |
|
|
bjlt
Senior Member
1144 Posts |
Posted - 11 May 2003 : 11:48:16
|
change Sub DoListUsersByState(pbPM,pbState,pbCity,pb) to Sub DoListUsersByState() sorry I'd changed my mind when I was writing it and as I said I could not test it. |
|
|
bjlt
Senior Member
1144 Posts |
Posted - 11 May 2003 : 11:54:40
|
also, if you changed it to state you don't need to use GetLocation(M_STATE,M_CITY), just use chkString(M_CITY,"display") instead.
also you can change the html design to match the other part of your sites.
You're welcome. I'm glad I can contribute to the snitz community a bit now. |
|
|
bjlt
Senior Member
1144 Posts |
Posted - 11 May 2003 : 12:01:30
|
please refer to the original codes for bug fixes, stated at the end of it.
also, I have some comment in the codes, please read them to customize for your own needs. AFAIK, current snitz uses male/female for sex but I used 1/2/3, all such things are marked by '# so please do read them. |
Edited by - bjlt on 11 May 2003 12:08:30 |
|
|
Topic |
|
|
|