How many new posts?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cbrian
Forum Commoner
Posts: 97
Joined: Sun Feb 27, 2005 12:29 pm

How many new posts?

Post 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?
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
cbrian
Forum Commoner
Posts: 97
Joined: Sun Feb 27, 2005 12:29 pm

Post by cbrian »

Well, I can't use cookies on this site. And this would probablymanually track every post the person has read.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post 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?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
cbrian
Forum Commoner
Posts: 97
Joined: Sun Feb 27, 2005 12:29 pm

Post by cbrian »

It boils down to either assigning a cutoff date
That's what I'm going to do.
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

If you can't use cookies, why not use a database?
Post Reply