PDA

View Full Version : Probably very easy: total # of posts today


futureal
28 Aug 2001, 08:30
Hi,

I am hoping I could add a little tidbit of info on my Forum Home display that, similar to "Total Posts: xx" and "Total Threads: xx" says something to the effect of "Total Posts Today: xx"

In an ideal world, it would only count posts on that particular day, thus resetting to zero at the midnight hour. It seems like something that should be pretty easy...

(but also makes me wonder, from an efficiency standpoint, if it's a good idea to be counting and re-counting all of the posts that day each time somebody loads the page...)

Also, I did do a search for this and only came up with a thread from almost a year ago where somebody asked a similar question but got no response.

So if anybody has a simple solution, thanks in advance! As you can see I am a PHP/MySQL newbie... learning a bit here and there... thanks!

Chen
29 Aug 2001, 18:24
Add this code:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


in index.php, right before


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------


Now you can use $poststoday anywhere in your forumhome template to show the number of posts today.

futureal
30 Aug 2001, 00:21
Thanks FireFly, works great!

futureal
30 Aug 2001, 01:04
I actually changed it a little bit. After some poking around on php.net I came up with this line:



Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



That will reset it at midnight of each day, according to the system time. The other version works for the past 24 hours.

Now that I've actually modified a line of PHP code all by myself, I feel quite special :) Thanks again!

Chen
30 Aug 2001, 05:47
No problem mate. :)

FWC
30 Aug 2001, 07:01
Now you can use $poststoday anywhere in your forumhome template to show the number of posts today.

Another cool one, FireFly. I am going to be in trouble when the next upgrade comes out. I can't stop myself! :D

Chen
30 Aug 2001, 07:14
Yeah I know what you mean.
Unless the next version is a major one (2.1.0), I don't think I'm gonna upgrade.
I have so many hacks installed, it's really tough! :(

But I'm glad you like this. :)