I've updated my profileLink() to the following:
function profileLink(fName, fID, fUserName)
dim strSql
dim rs_chk
'## Forum_SQL
strSql ="SELECT MEMBER_ID, M_LEVEL "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " WHERE MEMBER_ID = " & fID
Set rs_chk = Server.CreateObject("ADODB.Recordset")
rs_chk.open strSql, my_Conn
if rs_chk.BOF or rs_chk.EOF then
pmlev = 1
else
pmlev = rs_chk("M_LEVEL")
end if
rs_chk.close
set rs_chk = nothing
if instr(fName,"img src=") > 0 then
strExtraStuff = ""
else
strExtraStuff = " title=""View " & fUserName & "'s Profile""" & dWStatus("View " & fUserName & "'s Profile")
end if
if strUseExtendedProfile then
strReturn = "<a href=""pop_profile.asp?mode=display&id=" & fID & """" & strExtraStuff & ">"
else
strReturn = "<a href=""JavaScript:openWindow3('pop_profile.asp?mode=display&id=" & fID & "')""" & strExtraStuff & ">"
end if
if pmlev = 1 then
strmembercolor = ""
strmembercolorclose = ""
elseif pmlev = 2 then
strmembercolor = "<font color=""" & strAUModColor & """>"
strmembercolorclose = "</font>"
elseif pmlev = 3 or mlev = 4 then
strmembercolor = "<font color=""" & strAUAdminColor & """>"
strmembercolorclose = "</font>"
end if
profileLink = strReturn & strmembercolor & fName & strmembercolorclose & "</a>"
end function
The forums that I administer are not very active (usually 10 - 20 people active at a time), however, as you can see from the code, anytime a user is viewing a large thread there are quite a few database calls to look up what color a user's username should be. I was wondering if anyone could provide some ideas on enhancing the performance of this. I would like to retain the functionality of my current implementation, but limit the number of database calls. All opinions and ideas welcome!
Thanks so much.