Page 1 of 1
display image on new thread and updated
Posted: Tue Mar 01, 2005 4:04 am
by pleigh
i would like to know how to build logic on displaying an image when there is a new topic/thread, upon visiting it again, it will disappear, but when the there is a reply, or the message is updated, the image showing that there is a new message or there is a reply, will appear again.....
thanks
Posted: Tue Mar 01, 2005 4:13 am
by n00b Saibot
One SQL Query and a little tricky
if-then-else 
Posted: Tue Mar 01, 2005 4:17 am
by pleigh
thanks noob....but what could be the sql query you are refering to??i think i get the conditional part but the sql query is really stucking me...
Posted: Tue Mar 01, 2005 4:24 am
by n00b Saibot
see you are fetching all the data from the DB so there has to SQL right.
the query would be such that it looks if the topic has been seen first time or has been seen previously or has a new post. Simple enough.

Posted: Tue Mar 01, 2005 4:29 am
by pleigh
thanks noob, i think i'm tired now, that's why i'm not getting your point, an example query will be much appreciated....sorry...

Posted: Tue Mar 01, 2005 5:02 am
by n00b Saibot
Pseudo-SQL
Code: Select all
SELECT topic,posttime,viewtime,replytime from posts
Pseudo-PHP
Code: Select all
if(viewtime == 0 || viewtime < replytime) echo "<img src='newpost.gif'>{$topic}" //if not viewed or viewed before a reply was made, then show "new-post" image
else echo $topic //if viewing same post again, dont show image ;)
I hope i am able to make myself clear now

Posted: Tue Mar 01, 2005 8:19 am
by feyd
a seen field doesn't work well with multiple users.
You can store the "seen" data in a seperate table with the thread or post ids as the link to the posting system. When they are logged out, all their seen data is erased. The logic is, if it's not in the seen table and the thread/post has updated since they were last on.. they see a "new" indication. Otherwise, it's been seen previously so ignore.
it's also storable in a cookie, but limited in quantity.
At any rate, you may want to store the timestamp of when they last saw it new.
Posted: Wed Mar 02, 2005 12:00 am
by n00b Saibot
Ya that was what I suggested although not in such detailed manner

I thought he could make it out once logic was clear to him.
Posted: Wed Mar 02, 2005 12:27 am
by pleigh
thanks for the posts guys...i have here tables for posts and comments, i have done the sorting part of it, when someone posts, it is sorted by date DESC, as well as when someone comments.where do you think should i link the visits table?cause my idea here is, when someone posted a comment, the image will appear, otherwise, not.and i want to keep focus on the comments side....thanks for your time guys.
