PDA

View Full Version : Adding specific count of views


okc
12-19-2004, 05:19 AM
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 -

okc
12-20-2004, 12:02 AM
Anyone? thx

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 :)

okc
12-20-2004, 04:49 AM
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...

okc
12-20-2004, 04:30 PM
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

okc
12-20-2004, 06:10 PM
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