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

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: General / Classic ASP versions(v3.4.XX)
 Updating Site statistics
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

acech
Starting Member

26 Posts

Posted - 12 December 2005 :  09:14:41  Show Profile
Hi all,

Sorry to ask so many questions but I am very new to this!

Is there an easy way to update the statistics part of the website: ie 8 of 249 Members have made 13708 posts in 6 forums.

and is there a way to update the total posts per person?

I have recently merged several databases of different forums into one forum and so these statistics are out of line and I had hoped that the admin option to update counts would do this!

If there is no easy way I will write another script to do this for me, but I thought I would ask first!

Many Thanks,

Chris

Soar
Junior Member

USA
197 Posts

Posted - 12 December 2005 :  09:32:03  Show Profile  Visit Soar's Homepage
Have you tried the "Update Forum Count" link in the Admin Options page yet? I ask because I'm not sure it will do the trick, but it can't hurt.
Go to Top of Page

acech
Starting Member

26 Posts

Posted - 12 December 2005 :  09:37:11  Show Profile
Unfortunately not.. I was hoping that this would!

Thanks,

Chris
Go to Top of Page

acech
Starting Member

26 Posts

Posted - 12 December 2005 :  11:05:19  Show Profile
OK! I wrote a quick script to do this, and it has sorted everything out!

Thanks!

Chris
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 12 December 2005 :  12:37:36  Show Profile  Send pdrg a Yahoo! Message
Chris - is that script somethign you'd fancy sharing for the next person who wants to do this? If so, and if it's not too long, just post it up here, so others will find it when they search :)

Go to Top of Page

acech
Starting Member

26 Posts

Posted - 13 December 2005 :  12:01:14  Show Profile
Hi pdrg! Thank you for reminding me! I am very good at doing things and then not looking back! I am sure that there is potentially a way to do this already within Snitz, so I am not offereing this as an improved or better solution just one that worked. My problem was this - I had converted data from an old forum (users and messages) that I had written many years ago into the snitz database format. The page within the Admin Options labeled 'Update Forum Count' simply updated the forum counts and so I needed a way to update the counts of the individual users posts, or else they all started at 0, when some of the members had already posted hundreds of messages.

I will include the script I used below. I warn anyone following down this path that the script runs completely independantly from the snitz forum files - I only use an access database and so it will only work for an access database. It is also extremely inefficient, and badly written, but 'hey' it only had to run once! - So there is no point in pointing out how badly written or inefficient it is, it is just how I banged it in...!
Go to Top of Page

acech
Starting Member

26 Posts

Posted - 13 December 2005 :  12:02:37  Show Profile
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Server.ScriptTimeout = 600 ' This could take a while as the code is not very efficient!
dim conn, conn2

'Set the path to the database
sourceDB = "C:\Inetpub\wwwroot\yourAccessDatabase.mdb"
response.write("Database: " & sourceDB & "<br>")

Set conn=Server.CreateObject("ADODB.connection")
	conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & sourceDB
	Set rs = conn.Execute("SELECT * FROM FORUM_MEMBERS ORDER BY MEMBER_ID;")
		do while not rs.EOF
			response.write(rs.Fields("MEMBER_ID") & " " & rs.Fields("M_NAME") & " ")
			
			'ok lets count how many posts this user has made
			counter = 0
			Set conn2=Server.CreateObject("ADODB.connection")
			conn2.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & sourceDB
				Set rs2 = conn.Execute("SELECT * FROM FORUM_TOPICS WHERE T_AUTHOR=" & rs.Fields("MEMBER_ID") & " ORDER BY TOPIC_ID;")
				do while not rs2.eof
					counter = counter + 1
					rs2.movenext
				loop
				Set rs2 = conn.Execute("SELECT * FROM FORUM_REPLY WHERE R_AUTHOR=" & rs.Fields("MEMBER_ID") & " ORDER BY REPLY_ID;")
				do while not rs2.eof
					counter = counter + 1
					rs2.movenext
				loop
			
			response.write(counter & "<br>")
			
			'update the values
			Set rs2 = conn2.Execute("UPDATE [FORUM_MEMBERS] SET [M_POSTS]="& counter &" WHERE [MEMBER_ID]=" & rs.Fields("MEMBER_ID") & ";")
			conn2.close
			rs.movenext
		loop

response.write("Done!")
%>


Moderator Edit: Removed database name.

Edited by - Podge on 13 December 2005 13:19:25
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.25 seconds. Powered By: Snitz Forums 2000 Version 3.4.07