Page 1 of 1

How many new posts?

Posted: Sun Mar 27, 2005 4:25 pm
by cbrian
I'm working on making a forum, and I'm wondering how would you write a script that would say something like Chat(18 new posts). How would you get how many new posts?

Posted: Sun Mar 27, 2005 4:27 pm
by Ambush Commander
That's way too general. It boils down to either assigning a cutoff date: all posts after that are new, or manually tracking every post he has read (not recommended).

But I can't offer any specific solutions without seeing code.

Posted: Sun Mar 27, 2005 4:29 pm
by John Cartwright
Everytime a user enters a thread, set a cookie with the current time.
When they visit your site again, have a query like

Code: Select all

$sql = "SELECT COUNT(`id`) AS `total` FROM `posts` WHERE `time` >= '".$cookietime."'";
This requires that after each post is made, you include the current time.

Posted: Sun Mar 27, 2005 4:34 pm
by cbrian
Well, I can't use cookies on this site. And this would probablymanually track every post the person has read.

Posted: Sun Mar 27, 2005 4:36 pm
by Ambush Commander
If you want to manually track every post someone has read, you'll have to do it with some intelligent limiting, else you'll be handling huge files that have information on read and unread posts.

Posted: Sun Mar 27, 2005 4:45 pm
by John Cartwright
cbrian wrote:Well, I can't use cookies on this site. And this would probablymanually track every post the person has read.
Not really, after all this site uses cookies 8)
Ambush Commander wrote:If you want to manually track every post someone has read, you'll have to do it with some intelligent limiting, else you'll be handling huge files that have information on read and unread posts.
Agreed.

Posted: Sun Mar 27, 2005 5:46 pm
by d3ad1ysp0rk
Phenom wrote:Everytime a user enters a thread, set a cookie with the current time.
When they visit your site again, have a query like

Code: Select all

$sql = "SELECT COUNT(`id`) AS `total` FROM `posts` WHERE `time` >= '".$cookietime."'";
This requires that after each post is made, you include the current time.
Meaning if I visit a forum, view one topic, and then leave, it means I effectively viewed ALL topics?

Posted: Sun Mar 27, 2005 5:51 pm
by John Cartwright
No. You have then viewed all the posts in the topic.. :roll:

I assumed that you would have filled in the blanks, and assumed the more technical aspects of it were taken care of. Just trying to give him a nudge in the correct direction.

Posted: Mon Mar 28, 2005 4:42 pm
by cbrian
It boils down to either assigning a cutoff date
That's what I'm going to do.

Posted: Mon Mar 28, 2005 5:31 pm
by Pyrite
If you can't use cookies, why not use a database?