Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - MOD:Topic Count (MSSQL version)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

MOD:Topic Count (MSSQL version)

 Post Reply Post Reply Page  12>
Author
Ali Bilgrami View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 April 2005
Location: Pakistan
Status: Offline
Points: 492
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ali Bilgrami Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
Ali Bilgrami View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 April 2005
Location: Pakistan
Status: Offline
Points: 492
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ali Bilgrami Quote  Post ReplyReply Direct Link To This Post Posted: 30 December 2006 at 6:31am

***EDIT***

cleared to avoid confusion


Edited by Ali Bilgrami - 01 January 2007 at 7:45pm
Lets!
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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 *
S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
Ali Bilgrami View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 April 2005
Location: Pakistan
Status: Offline
Points: 492
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ali Bilgrami Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post Posted: 31 December 2006 at 2:23pm
are you acctually adding the value to the database?

wheres the

rsCommon("No_of_topic") = intTopics
S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
Ali Bilgrami View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 April 2005
Location: Pakistan
Status: Offline
Points: 492
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ali Bilgrami Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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
S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
Ali Bilgrami View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 April 2005
Location: Pakistan
Status: Offline
Points: 492
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ali Bilgrami Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.