save percentage deleted posts/user

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/61454?pagenum=1
05 November 2025, 07:04

Topic


tribaliztic
save percentage deleted posts/user
30 March 2006, 03:56


I saw a function on another forum that I would like to have... In all users profiles there was a percentage of how many post that had been deleted of the total post count on that user. I did a brain fart and had a quick look at pop_delete.asp. Is it as simple as adding this (please check the code for errors...) to pop_delete.asp to add "1" to M_DELPOST for the user that did the post/reply?
Under case "DeleteReply":

strSql = " UPDATE " & strMemberTablePrefix & "MEMBERS M" & _
"SET M.M_DELPOST = M.M_DELPOST + 1 "" & _
" WHERE M.MEMBER_ID = T.R_AUTHOR "

my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords

Under case "DeleteTopic":

strSql = " UPDATE " & strMemberTablePrefix & "MEMBERS M" & _
"SET M.M_DELPOST = M.M_DELPOST + 1 "" & _
" WHERE M.MEMBER_ID = T.R_AUTHOR "

my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords

Then just get that figure from the db and run it against total post count on the user and show the percentage in his/her profile.
Am I totally in the blue here? =)<

 

Replies ...


Shaggy
30 March 2006, 06:21


It can be done without the need for an additional field; grab the number of posts a member has made from the TOPICS and REPLY tables, subtract that from M_POSTS and use the resulting figure to calculate your percentage. The drawback to this solution is that it requires an extra database hit.
<
tribaliztic
30 March 2006, 06:28


It would only be used when viewing a profile so one extra hit wouldn't be that much of a problem.
So, something like:

COUNT("SELECT TOPICS FROM FORUM_TOPICS WHERE T_AUTHOR = ppMEMBER_ID" + "SELECT REPLIES FROM FORUM_REPLIES WHERE R_AUTHOR = ppMEMBER_ID") AS MEMBER_POST_COUNT
to count the number of posts?
Then like:
COUNT("M_POSTS - MEMBER_POST_COUNT") AS MEMBER_POST_PERCENTAGE

I have no clue how the syntax should be, I'm just having another brainfart..
(I really like that word =))
<
Shaggy
30 March 2006, 06:45


What database are you using again so's I can give you the necessary code?
<
tribaliztic
30 March 2006, 06:46


MySQL, sorry =)
<
Shaggy
30 March 2006, 06:52


You don't know what version, do you? Going to try and do it with a nested query but older versions of MySQL don't support them.
<
tribaliztic
30 March 2006, 06:59


DBMS Name MySQL
DBMS Version 4.0.20a-nt

I suppose this is the mysql version, found it in admin home under "server information". <
Shaggy
30 March 2006, 07:09


Hmm ... think that version should support nested queries so give the following a try:
Code:
set rscount=my_conn.execute("SELECT COUNT(*) AS inttcount, (SELECT COUNT(*) AS intrcount FROM "&strTablePrefix&"REPLY WHERE R_AUTHOR="&ppMember_ID&") FROM "&strTablePrefix&"TOPICS WHERE T_AUTHOR="&ppMember_ID)
intpcount=clng(rscount("inttcount"))+clng(rs("intrcount"))
rscount.close
set rscount=nothing
intdpercentage=abs(round(((intTotalMemberPosts-intpcount)/intTotalMemberPosts)*100))
<
tribaliztic
30 March 2006, 07:14


heh, that query looks more cool than mine ;)

Thanks alot! I'll give it a try! <
Shaggy
30 March 2006, 07:15


You're welcome smile
<
tribaliztic
30 March 2006, 08:35


Oops, I got this:

Microsoft OLE DB Provider for ODBC Drivers fel '80040e14'
[MySQL][ODBC 3.51 Driver][mysqld-4.0.20a-nt]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT COUNT(*) AS intrcount FROM FORUM_REPLY WHERE R_AUTHOR=50

/pop_profile.asp, line 839

also, this won't count archived posts I suppose? <
tribaliztic
03 April 2006, 06:23


Shaggy: you think there is a problem with the mysql version? I get the same error when running the sql directly into the db.
<
tribaliztic
13 April 2006, 03:05


No luck on this one yet, anyone have any ideas? <
tribaliztic
18 April 2006, 10:20


bumpetibump... Shaggy: do you think it has something to do with the db version? <
tribaliztic
03 May 2006, 04:56


I just noticed that this error only show if the user has done any posts... <
tribaliztic
09 May 2006, 09:55


Any MySQL-guru out there that can have a look at the sql-string?<
tribaliztic
17 May 2006, 05:08


I solved this by splitting the sql-string like this:

if intTotalMemberPosts > 0 then
set rscount1=my_conn.execute("SELECT COUNT(*) AS inttcount FROM "&strTablePrefix&"TOPICS WHERE T_AUTHOR="&ppMember_ID&"")
set rscount2=my_conn.execute("SELECT COUNT(*) AS intrcount FROM "&strTablePrefix&"REPLY WHERE R_AUTHOR="&ppMember_ID&"")
intpcount=clng(rscount1("inttcount"))+clng(rscount2("intrcount"))
rscount1.close
rscount2.close

set rscount1=nothing
set rscount2=nothing
intdpercentage=abs(round(((intTotalMemberPosts-intpcount)/intTotalMemberPosts)*100))

Is there any reason I can't do it like this? I get a number and it might be correct.. I can't really tell =)
<
Shaggy
17 May 2006, 05:14


Nope, no reason at all; it does the same thing. Curious as to why the nested query didn't work, though, maybe that version of MySQL just doesn't support them - can you response.write it and post it here 'til we double check?
<
tribaliztic
17 May 2006, 05:47


What do you want response write:d? =)
The splitted string or the first string? <
Shaggy
17 May 2006, 05:49


My original, nested query.
<
tribaliztic
17 May 2006, 06:49


I can't do a response.write since I get an error on the sql-string before the response.write is done.. Or can I do it in another way? <
© 2000-2021 Snitz™ Communications