| Author |
Topic Search Topic Options
|
Ali Bilgrami
Senior Member
Joined: 14 April 2005
Location: Pakistan
Status: Offline
Points: 492
|
Post Options
Thanks(0)
Quote Reply
Topic: MOD:Topic Count (MSSQL version) Posted: 30 December 2006 at 5:01am |
It is done...so here are the details
1-There are 4 files to be modified
- forum_posts.asp
- member_profile.asp
- new_post.asp
- language_file_inc.asp
2-There is one database change to be made
- Adding a field in tblAuthor (No_Of_Topics)
I'll start with Step 2 first...since this is the easiest one 
2- Open up your MSSQL database using MS SQL Server Enterprise Manager
- Open the table (tblAuthor) in design view
- Add a field named (No_Of_Topics [Data Type=int, Length=4, Allow Null=Yes, Default Value=(0), Identity=No)
- Click on Save Table icon & exit
Now to the other part
lets start with
language_file_inc.asp
- Open the file
- Add this at any place in the file (Const strTxtTopicsPerDay = "topics per day")
- Save & exit
new_post.asp
- Open the file
- Under 'Dimension variables define this variable (Dim intTopics)
- Under '*** Update Author Number of Posts *** Replace the SQL query with this one ('Initalise the strSQL variable with an SQL statement to query the database to get the number of posts the user has made
strSQL = "SELECT " & strDbTable & "Author.No_of_posts, " & strDbTable & "Group.Special_rank, " & strDbTable & "Author.No_Of_Topics " & _ "FROM " & strDbTable & "Author " & strDBNoLock & ", " & strDbTable & "Group " & strDBNoLock & " " & _ "WHERE " & strDbTable & "Author.Group_ID=" & strDbTable & "Group.Group_ID " & _ "AND " & strDbTable & "Author.Author_ID=" & lngLoggedInUserID & ";")
- Just couple of lines after that find this code ['Read in the no of posts the user has made and username
lngNumOfPosts = CLng(rsCommon("No_of_posts"))] and add after it ['Read in the no of topics the user has made and username intTopics = Clng(rsCommon("No_Of_Topics"))]
- Just after that find the code ['Inrement the number of posts by 1
lngNumOfPosts = lngNumOfPosts + 1] and add after it [if strMode = "new" OR strMode = "poll" then intTopics = intTopics + 1]
- Just after that find the SQL UPDATE query ['Initalise the SQL string with an SQL update command to update the number of posts the user has made
strSQL = "UPDATE " & strDbTable & "Author " & strRowLock & " " & _ "SET " & strDbTable & "Author.No_of_posts = " & lngNumOfPosts " " & _ "WHERE " & strDbTable & "Author.Author_ID = " & lngLoggedInUserID & ";"] and replace it with ['Initalise the SQL string with an SQL update command to update the number of posts the user has made strSQL = "UPDATE " & strDbTable & "Author " & strRowLock & " " & _ "SET " & strDbTable & "Author.No_of_posts = " & lngNumOfPosts & ", " & strDbTable & "Author.No_Of_Topics = " & intTopics & " " & _ "WHERE " & strDbTable & "Author.Author_ID = " & lngLoggedInUserID & ";"]
- Save & Exit
member_profile.asp
- Open the file
- In Dimension Variable list define this variable (Dim intNoOfTopics)
- Find this code [strMemberTitle = rsCommon("Avatar_title")] under ('Read in the new user's profile from the recordset) and add after it [if isNumeric(rsCommon("No_Of_Topics")) then intNoOfTopics = Clng(rsCommon("No_Of_Topics")) else intNoOfTopics= 0]
- Find this code [<tr>
<td><% = strTxtPosts %>:</td> <td><% = lngNumOfPosts %> <% If lngNumOfPosts > 0 AND DateDiff("d", dtmJoined, Now()) > 0 Then Response.Write(" [" & FormatNumber(lngNumOfPosts / DateDiff("d", dtmJoined, Now()), 2) & " " & strTxtPostsPerDay) & "]" %></td> </tr>] and add after it [<tr> <td><% = strTxtTopics %>:</td> <td><% = intNoOfTopics %> <% If intNoOfTopics > 0 AND DateDiff("d", dtmJoined, Now()) > 0 Then Response.Write(" [" & FormatNumber(intNoOfTopics / DateDiff("d", dtmJoined, Now()), 2) & " " & strTxtTopicsPerDay) & "]" %></td> </tr>]
- Save & Exit
forum_posts.asp
- Open the file
- In Dimension Variables define this variable [Dim intTopics]
- Find this query ['Intilise SQL query to get all the posts
'Use a LEFT JOIN for the Guest name as there may not be a Guest name and so we want to include null values strSQL = "" & _ "SELECT " & strDbTable & "Thread.Thread_ID, " & strDbTable & "Thread.Message, " & strDbTable & "Thread.Message_date, " & strDbTable & "Thread.Show_signature, " & strDbTable & "Thread.IP_addr, " & strDbTable & "Thread.Hide, " & strDbTable & "Author.Author_ID, " & strDbTable & "Author.Username, " & strDbTable & "Author.Homepage, " & strDbTable & "Author.Location, " & strDbTable & "Author.No_of_posts, " & strDbTable & "Author.Join_date, " & strDbTable & "Author.Signature, " & strDbTable & "Author.Active, " & strDbTable & "Author.Avatar, " & strDbTable & "Author.Avatar_title, " & strDbTable & "Group.Name, " & strDbTable & "Group.Stars, " & strDbTable & "Group.Custom_stars, " & strDbTable & "GuestName.Name " & _] and replace it with this one ['Intilise SQL query to get all the posts 'Use a LEFT JOIN for the Guest name as there may not be a Guest name and so we want to include null values strSQL = "" & _ "SELECT " & strDbTable & "Thread.Thread_ID, " & strDbTable & "Thread.Message, " & strDbTable & "Thread.Message_date, " & strDbTable & "Thread.Show_signature, " & strDbTable & "Thread.IP_addr, " & strDbTable & "Thread.Hide, " & strDbTable & "Author.Author_ID, " & strDbTable & "Author.Username, " & strDbTable & "Author.Homepage, " & strDbTable & "Author.Location, " & strDbTable & "Author.No_of_posts, " & strDbTable & "Author.Join_date, " & strDbTable & "Author.Signature, " & strDbTable & "Author.Active, " & strDbTable & "Author.Avatar, " & strDbTable & "Author.Avatar_title, " & strDbTa
|
|
Lets!
|
 |
Ali Bilgrami
Senior Member
Joined: 14 April 2005
Location: Pakistan
Status: Offline
Points: 492
|
Post Options
Thanks(0)
Quote Reply
Posted: 30 December 2006 at 6:31am |
***EDIT***
cleared to avoid confusion
Edited by Ali Bilgrami - 01 January 2007 at 7:45pm
|
|
Lets!
|
 |
Scotty32
Moderator Group
Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
|
Post Options
Thanks(0)
Quote Reply
Posted: 30 December 2006 at 10:54am |
|
forget line 932, post the strSQL for that line - that would help better.
also, wouldnt you want to do:
* connect to user *
if new then update topic else update post end if
*disconnect from user *
|
|
|
 |
Ali Bilgrami
Senior Member
Joined: 14 April 2005
Location: Pakistan
Status: Offline
Points: 492
|
Post Options
Thanks(0)
Quote Reply
Posted: 30 December 2006 at 9:47pm |
here is the strSQL
------------------------
'Initalise the strSQL variable with an SQL statement to query the database to get the number of posts the user has made strSQL = "SELECT " & strDbTable & "Author.No_of_posts, " & strDbTable & "Group.Special_rank, " & strDbTable & "Author.No_of_topic" & _ "FROM " & strDbTable & "Author " & strDBNoLock & ", " & strDbTable & "Group " & strDBNoLock & " " & _ "WHERE " & strDbTable & "Author.Group_ID=" & strDbTable & "Group.Group_ID " & _ "AND " & strDbTable & "Author.Author_ID=" & lngLoggedInUserID & ";"
--------------------
doesnt THIS
------------------
lngNumOfPosts = lngNumOfPosts + 1
if strMode = "new" OR strMode = "poll" then intTopics = intTopics + 1
------------------
do the increament in topic count if its a topic and also posts? cuz a topic is also a post, isnt it? if it can be better put (my asp aint that good after all  ) kindly do so :)
|
|
Lets!
|
 |
Scotty32
Moderator Group
Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
|
Post Options
Thanks(0)
Quote Reply
Posted: 31 December 2006 at 2:23pm |
|
are you acctually adding the value to the database?
wheres the
rsCommon("No_of_topic") = intTopics
|
|
|
 |
Ali Bilgrami
Senior Member
Joined: 14 April 2005
Location: Pakistan
Status: Offline
Points: 492
|
Post Options
Thanks(0)
Quote Reply
Posted: 31 December 2006 at 8:10pm |
and added after this
'Read in the no of posts the user has made and username lngNumOfPosts = CLng(rsCommon("No_of_posts")) |
THIS
intTopics = Clng(rsCommon("No_of_topic")) | there it is...just not in order how you wrote i think ...
Happy new year btw :)
|
|
Lets!
|
 |
Scotty32
Moderator Group
Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
|
Post Options
Thanks(0)
Quote Reply
Posted: 01 January 2007 at 12:26am |
|
thats retriving the value, not setting it - hense why your Topic Count is never updating.
you need to find where it updates the user, and add code to update the Topic Count
|
|
|
 |
Ali Bilgrami
Senior Member
Joined: 14 April 2005
Location: Pakistan
Status: Offline
Points: 492
|
Post Options
Thanks(0)
Quote Reply
Posted: 01 January 2007 at 6:10pm |
|
since it is in the new_post.asp which has nothing to do with retrieving topic count (that is in forum_posts.asp) so i think i should change the order ... lemme check that...i'll get back to you on this one
|
|
Lets!
|
 |