Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 how do i display 5 newest members on my portal
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

pokemon
Junior Member

151 Posts

Posted - 02 February 2004 :  12:34:43  Show Profile
How do i change a code below to display 5 newest members in my portal? Thanks

Dim Forum_Count
Dim NewMember_Name, NewMember_Id, Member_Count
Dim LastPostDate, LastPostLink

Forum_Count = intForumCount
'## Forum_SQL - Get newest membername and id from DB

strSql = "SELECT M_NAME, MEMBER_ID FROM " & strMemberTablePrefix & "MEMBERS " &_
" WHERE M_STATUS = 1 AND MEMBER_ID > 1 " &_
" ORDER BY MEMBER_ID desc;"

set rs = Server.CreateObject("ADODB.Recordset")
rs.open TopSQL(strSql,1), my_Conn

if not rs.EOF then
NewMember_Name = chkString(rs("M_NAME"), "display")
NewMember_Id = rs("MEMBER_ID")
else
NewMember_Name = ""
end if

rs.close
set rs = nothing

if NewMember_Name <> "" then
Response.Write " <tr>" & vbNewline & _
" <td bgcolor=""" & strForumCellColor & """ colspan=""" & sGetColspan(6,5) &_
""">" & _
"<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" & strForumFontColor & """>welcome & _
"<span class=""spnMessageText"">" & profileLink(NewMember_Name,NewMember_Id) & "</span>.</font></td>" & vbNewline & _
" </tr>" & vbNewline
end if

Cliff
Average Member

United States
501 Posts

Posted - 02 February 2004 :  12:40:01  Show Profile  Visit Cliff's Homepage
This should work in Access / MS SQL:

strSql = "SELECT Top 5   M_NAME, MEMBER_ID FROM " & strMemberTablePrefix & "MEMBERS " &_
" WHERE M_STATUS = 1 AND MEMBER_ID > 1 " &_
" ORDER BY MEMBER_ID desc;"


This should work in MySQL:
strSql = "SELECT M_NAME, MEMBER_ID FROM " & strMemberTablePrefix & "MEMBERS " &_
" WHERE M_STATUS = 1 AND MEMBER_ID > 1 " &_
" ORDER BY MEMBER_ID desc Limit 5;"
Go to Top of Page

pokemon
Junior Member

151 Posts

Posted - 02 February 2004 :  12:49:29  Show Profile
it not work with Top 5. I don't know why...It works without Top 5, but only show one member. Would you please verify? Thanks
Go to Top of Page

miperez
Junior Member

Spain
243 Posts

Posted - 02 February 2004 :  12:55:04  Show Profile
Why don't you use the TopSQL function provided by Snitz itself? You can find it in inc_fuinc_common, and it performs the appropriate changes for each database.

It's declared as:

Function TopSQL(strSQL, lngRecords)

Edit: I just saw the code you posted above. So, in order to show 5 members, change the digit inside the TopSQL function from 1 to 5, like this:
rs.open TopSQL(strSql,5), my_Conn

Best Regards

Mikel Perez

"Hell is the place where everything test perfectly, and nothing works"

Edited by - miperez on 02 February 2004 12:58:09
Go to Top of Page

pokemon
Junior Member

151 Posts

Posted - 02 February 2004 :  14:44:05  Show Profile
i changed to 5 like this: rs.open TopSQL(strSql,5), my_Conn, but nothing will work.
Go to Top of Page

pokemon
Junior Member

151 Posts

Posted - 02 February 2004 :  15:58:27  Show Profile
i changed TopSQL to 5 like this: but it still showing up only one member. Anyone know how to fix it.

'## Forum_SQL - Get newest membername and id from DB

strSql = "SELECT M_NAME, MEMBER_ID FROM " & strMemberTablePrefix & "MEMBERS " &_
" WHERE M_STATUS = 1 AND MEMBER_ID > 1 " &_
" ORDER BY MEMBER_ID desc;"


set rs = Server.CreateObject("ADODB.Recordset")
iTopNewNum = 5
rs.open TopSQL(strSql,iTopNewNum), my_Conn

if not rs.EOF then
NewMember_Name = chkString(rs("M_NAME"), "display")
NewMember_Id = rs("MEMBER_ID")
else
NewMember_Name = ""
end if

rs.close
set rs = nothing

if NewMember_Name <> "" then
Response.Write " <tr>" & vbNewline & _
" <td bgcolor=""" & strForumCellColor & """ colspan=""" & sGetColspan(6,5) &_
""">" & _
"<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" & strForumFontColor & """>welcome: " & _
"<span class=""spnMessageText"">" & profileLink(NewMember_Name,NewMember_Id) & "</span>.</font></td>" & vbNewline & _
" </tr>" & vbNewline
end if
Go to Top of Page

miperez
Junior Member

Spain
243 Posts

Posted - 03 February 2004 :  04:18:27  Show Profile
Hi, pokemon.

I have reviewed it, and is happening because of how the code is written. No matter how many records you retrieve from the database, the code afterwards just reads the first one, close the records, and print that single one.

I am not an expert in ASP, but I think that in order to change it, you could do the following: enclose the if.. end if statements inside a do...while loop, and close the recordset outside the loop:


do
if not rs.EOF
   NewMember_Name = chkString(rs("M_NAME"), "display")
   NewMember_Id = rs("MEMBER_ID")
   rs.movenext
else
   'NewMember_Name = ""
   exit do
end if

if NewMember_Name <> "" then 
Response.Write " <tr>" & vbNewline & _
" <td bgcolor=""" & strForumCellColor & """ colspan=""" & sGetColspan(6,5) &_
""">" & _
"<font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """ color=""" & strForumFontColor & """>welcome: " & _
"<span class=""spnMessageText"">" & profileLink(NewMember_Name,NewMember_Id) & "</span>.</font></td>" & vbNewline & _
" </tr>" & vbNewline
end if
while not rs.EOF

rs.close
set rs = nothing


Make a backup of your files before trying these changes, OK?

Tell me if this has worked...

Best Regards

Mikel Perez

"Hell is the place where everything test perfectly, and nothing works"

Edited by - miperez on 03 February 2004 04:29:09
Go to Top of Page

pokemon
Junior Member

151 Posts

Posted - 06 February 2004 :  16:49:28  Show Profile
thanks, it works....you are the man
Go to Top of Page

miperez
Junior Member

Spain
243 Posts

Posted - 09 February 2004 :  03:50:50  Show Profile
Glad that helped, really. Cheers!!

Best Regards

Mikel Perez

"Hell is the place where everything test perfectly, and nothing works"
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.36 seconds. Powered By: Snitz Forums 2000 Version 3.4.07