PDA

View Full Version : Total number of views for all posts per member


Logtenberg
11-15-2001, 09:04 PM
I want to give members the satisfaction of seeing how many views all their posts have received.

i.e.
Total views of all your posts: 34500

Anyone one know if this hack has been done?

Admin
11-16-2001, 11:18 AM
So, to sum all the views of the threads started by the person viewing the page? Not hard at all.
Tell me if this is what you want. :)

Logtenberg
11-16-2001, 04:57 PM
I was going to put this information in their control panel, for each members own private reference.

Logtenberg
11-22-2001, 05:22 AM
I have just realized that this is a more important requirement for my message boards then I thought.

If no one knows how to do it, can anyone point me to a hack that is similar?

I must say, that this would be a great hack. - It could double for a points program. - The person must be the thread starter however to count the impressions towards their total...

thanks.

christec
11-22-2001, 05:41 AM
Something like this:

$DB_site->query("SELECT count(views) FROM thread WHERE postusername=$bbuserinfo[username]");

Admin
11-22-2001, 11:49 AM
$yourviews=$DB_site->query_first("SELECT SUM(views) AS totalviews FROM thread WHERE postuserid='$bbuserinfo[userid]'");
is more like it. :)

christec
11-22-2001, 02:21 PM
OK, how about a short, quick explanation of "query_first".

Admin
11-22-2001, 03:22 PM
$DB_site->query() is just like mysql_query().

$DB_site->query_first() is the same as the above, only it returns the first row in the result.

For example if you want to find out someone's username, you can do this:
$userinfo=$DB_site->query_first("SELECT username FROM user WHERE userid='$userid'");
And then you can just use $userinfo[username].

But if you do it this way (the wrong way):
$userinfo=$DB_site->query("SELECT username FROM user WHERE userid='$userid'");
(i.e using query instead of query_first)
You must do $DB_site->fetch_array(), because the result in this case it a 2D array.

Am I making sense here? :)

Lesane
11-22-2001, 03:46 PM
Thanks Firefly, learned something 2day :)

Why not making a new forum where the php guys can add their little tutorials like this one above? ;)

christec
11-22-2001, 04:35 PM
Originally posted by FireFly
Am I making sense here? :)
Crystal clear!
One more question, which file is this object defined in?

Thank You
:D

Admin
11-22-2001, 04:46 PM
Like all $DB_site, db_mysql.php.

christec
11-22-2001, 05:01 PM
Duh! I should have known, my brain is enjoying the holiday.
Thanks again

Logtenberg
11-23-2001, 06:16 PM
Originally posted by FireFly
$yourviews=$DB_site->query_first("SELECT SUM(views) AS totalviews FROM thread WHERE postuserid='$bbuserinfo[userid]'");
is more like it. :)


Hey Firefly,

Where exactly does this code go? I put it in one of the cp templates and that didn't work.

Thanks!

Admin
11-23-2001, 06:30 PM
In index.php, add this:
$countviews=$DB_site->query_first("SELECT SUM(views) AS views FROM thread WHERE postuserid='$bbuserinfo[userid]'");
$yourviews=number_format($countviews['views']);
right before this:
// get newest member
Now use $yourviews in your forumhome template to show the number.

squawell
11-24-2001, 08:22 AM
FireFly~~

can it show up in postbit~~

i want to do that u know how to do that??

Admin
11-24-2001, 08:32 AM
Yeah I do, but it takes too much resource.

squawell
11-24-2001, 09:38 AM
i know~~but i still want to know~

can u tell me how to do that??plz~~

Admin
11-24-2001, 11:15 AM
In functions.php, find this:

eval("\$post[profile] = \"".gettemplate("postbit_profile")."\";");
after that, add this:
$countviews=$DB_site->query_first("SELECT SUM(views) AS views FROM thread WHERE postuserid='$post[userid]'");
$post[hisviews]=number_format($countviews['views']);
Now you can use $post[hisviews] in your postbit template.

This hack is bad for your server! I don't advice using it!

squawell
11-24-2001, 11:25 AM
thankz FireFly ur advice~~~

u let me know more about vbb hack's code~~

and i just want to know if i want to do what should i do??

that's all~~:D

Logtenberg
11-26-2001, 11:19 PM
Thanks for your advice on this matter firefly.

I would like to insert the total views into the control panel for the member as well as in the "forumhome_pmloggedin" template.

It doesn't seem to work when I insert this code into that template. Can you tell me what I need to do to get this to work?

thanks.

king98
04-11-2002, 10:19 AM
Is there any way to get the number of threads that you have visited ?

e.g: this member has read: 45152 threads(or posts).