PDA

View Full Version : Letter counter in getinfo for all posts by a user!


Sho
03-15-2003, 05:57 AM
Hi there,

I really want a letter counter for my forums :). A user writes a post and the number of letters it contains is added to his counter. Of course, 'editpost' has to be considered, too. The counter should show up in getinfo. Now, all in all, I understand what has to be done, but my SQL is too bad to figure out how to count the letters in the existing posts and where to insert them. I tried it with some simple loops, printing out per userid, but ... well, I'm not up to it.

Since I'm posting this in "Hack Requests", I'm obviously shooting for a complete solution :cheeky:. But if someone takes the time to post some PHP/SQL code on how to count the letters in the existing posts and gives advice on which database structure would be best (I'm guessing the best would be a new field in the user table containing the calculated number, constantly updated by newreply/newthread/editpost; counting anew every time would result in an extreme load), I might be able to try it on my own again.

Anyway, thanks for reading. :)

Logician
03-15-2003, 07:01 AM
I bet Xenon provided this code in this forum, but I couldnt find its thread when I searched now. You can try to search maybe you can be luckier than me, or maybe Xenon can point it.. :)

Sho
03-15-2003, 08:01 AM
Xenon did provide me with code to display the letter count of the respective post in the postbit template once, but that's not what I need. I want an ongoing counter and I have to count the letters of the existing posts per user before. :)

Sho
03-15-2003, 09:39 AM
Ah, I got it to work (http://www.forenplanet.de/member.php?s=&action=getinfo&userid=450) ("Buchstaben" = letters). Logician posted a way to do it dynamically in the old thread, I added it to member.php:

SELECT SUM(LENGTH(pagetext)) FROM `post` WHERE userid='$userid'

Sorry. I didn't notice the new posts in the old thread (https://vborg.vbsupport.ru/showthread.php?s=&threadid=43729&highlight=letter), should've looked at it before posting a new one.

Thanks Logician, anyway. :)

Logician
03-15-2003, 09:48 AM
yw.. even I didn't remember I gave the code before :)

Sho
03-15-2003, 02:59 PM
<a href="http://www.forenplanet.de/member.php?s=&action=getinfo&userid=450" target="_blank">Now it shows</a> the number of letters, how many letters per day, how many letters of all letters by all members in percent and how many letters per post on average. Maybe I should publish all this as a new hack. Of course, I'd credit you, Logician. What do you say?

Logician
03-15-2003, 07:07 PM
sure go ahead and publish it if you want to..

Xanthine
03-15-2003, 07:13 PM
Please do as Im interested in this as well

Sho
03-16-2003, 03:12 AM
Cool, thanks a lot Logician!

Xanthine, expect a hack in 10 - 15 hours, I'll do it when it's evening for me over here.

Sho
03-16-2003, 05:02 AM
Well, what the hell. Here ya go, Xanthine:

https://vborg.vbsupport.ru/showthread.php?s=&threadid=50249