display image on new thread and updated

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
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

display image on new thread and updated

Post 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
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

One SQL Query and a little tricky if-then-else :D
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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...
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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. :)
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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... :oops:
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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'>&#123;$topic&#125;" //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 :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post 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.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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. :)
Post Reply