View Full Version : Adding specific count of views
Someone suggested I add the following code if I want to put the totalviews of a forum onto the forumdisplay page, instead of total posts.
SELECT SUM(views) FROM thread
I think I need a number value string (right?) - what do you suggest and where can I place it to generate the totalviews?
thx for your help -
Colin F
12-20-2004, 03:52 AM
well you'll want to limit that to a specific forum:
SELECT SUM(views) AS views FROM " . TABLE_PREFIX . "thread WHERE forumid = $forumid
or, do it with something like GROUP BY forumid.
Now that I think about it, the second would be even better :)
So
SELECT SUM(views) AS views FROM " . TABLE_PREFIX . "thread GROUP BY forumid = $forumid ???
& what table should I add it to in mysql?
Will it generate a number I can use in my boards -
thx!
Colin F
12-20-2004, 03:09 PM
you could cache it in the datastore table...
that should generate a number, which you can call in your boards, but you'll have to fetch it from the database then...
Thx - is this the correct GROUP BY string?
SELECT SUM(views) AS views FROM " . TABLE_PREFIX . "thread GROUP BY forumid = $forumid
& how do I call it back from the datastore? - it doesn't appear to have a name like $threadviews...
Colin F
12-20-2004, 05:25 PM
no, just GROUP BY forumid
you'll have to add it to the datastore first
Bear with me, Colin - sorry for the newbie questions -
So i can put the string into the data store, but how would I have it display within forumdisplay on my board - what do I ask for to get that value? i.e. $threadviews
Thx
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.