Counting new posts logically (confused myself)

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
tony montana
Forum Newbie
Posts: 21
Joined: Tue Sep 28, 2004 11:10 am

Counting new posts logically (confused myself)

Post by tony montana »

Ok so basically when a user posts a new reply or views a thread then there last visit time is updated. However if I go on a diffrent browser then I still get the count of new posts - even if they are my own.

The query as it is;

Code: Select all

SELECT * 
				FROM $forumzDB.forumz_posts p 
				JOIN $forumzDB.forumz_threads t ON (p.tid = t.tid)
				JOIN $forumzDB.forumz_forums f ON (t.fid = f.fid) 
				WHERE p.time > ".$_COOKIEї'last_visit']." 
				AND f.level <= ".$user_properties&#1111;'status_id']."
				AND f.type != 'lock'
				AND p.uid != ".$user_properties&#1111;'uid']."
				ORDER BY p.time ASC
Ok so I ran this through phpmyadmin and it showed that the query was counting the posts in threads I was the last poster in - BUT all it wasnt doing was counting my own when really it should look and go `hey, your the last poster (AND p.uid != ".$user_properties['uid'].") and we dont count in that thread.

So Im confused how to incorporate that and the more I think about it the more I confuse myself, help :)
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Many browsers dont share the cookies and so you wouldnt be able to get that value from the user. A better way would be to store the value for the user id and then when the user logs in - with any browser - it will have it correct. You just have to set the cookie for people who are not logged in, and they shouldnt expect the info to be stored as they havent identified themselfs to the site.
Post Reply