How to display only new updates (new user photo, new comment

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
meee
Forum Newbie
Posts: 18
Joined: Wed Feb 04, 2009 1:38 pm

How to display only new updates (new user photo, new comment

Post by meee »

Please help me if you have any idea how would you solve the following problem:
I want to display to user on home page a notification when a friend of user changes profile. Changes can be new video, new photo, new comment.

In each notification will be an information about who did change, what kind of change he/she did and time.

I was thinking to put all changes into new table (columns: ID, userID, changeTitle, time) but I don't know how to display only new updates (which weren't displayed in user home page yet), not all of them.

Thank you
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How to display only new updates (new user photo, new comment

Post by Benjamin »

Can you post your code?
mickeyunderscore
Forum Contributor
Posts: 129
Joined: Sat Jan 31, 2009 9:00 am
Location: UK

Re: How to display only new updates (new user photo, new comment

Post by mickeyunderscore »

When a user logs in, could you save the current time in the database? Then you could easily fetch everything which is newer than their last login.
meee
Forum Newbie
Posts: 18
Joined: Wed Feb 04, 2009 1:38 pm

Re: How to display only new updates (new user photo, new comment

Post by meee »

mickeyunderscore thanks I think I almost know now how to do. Now I just don't know how to delete all older rows older than previous one, not older than current one. So I need to keep current time and previous one until user log in again.
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: How to display only new updates (new user photo, new comment

Post by watson516 »

meee wrote:mickeyunderscore thanks I think I almost know now how to do. Now I just don't know how to delete all older rows older than previous one, not older than current one. So I need to keep current time and previous one until user log in again.
Wouldn't you need to keep it in case other people require that information as well? Unless you only display this information to one user, once.
meee
Forum Newbie
Posts: 18
Joined: Wed Feb 04, 2009 1:38 pm

Re: How to display only new updates (new user photo, new comment

Post by meee »

watson516 wrote:
meee wrote:mickeyunderscore thanks I think I almost know now how to do. Now I just don't know how to delete all older rows older than previous one, not older than current one. So I need to keep current time and previous one until user log in again.
Wouldn't you need to keep it in case other people require that information as well? Unless you only display this information to one user, once.
I was thinking to create new table LoginTime with columns: userID, cLogin (as current login time) and pLogin (as previous log in time). Second table would be Changes.

Then I will display all rows from table Changes in period of time between cLogin and pLogin from table LoginTime where userID is same as user. For every new login information will be displayed and then cLogin (current login from previous login) will be inserted into pLogin and current login time into cLogin.

Does mysql a function to call the oldest or the newest row?
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: How to display only new updates (new user photo, new comment

Post by watson516 »

meee wrote: Does mysql a function to call the oldest or the newest row?
You can Order your results by date.

Code: Select all

<?php
$q="SELECT * FROM table ORDER BY date DESC";
$result=mysql_query
?>
DESC for descending or ASC (I believe this is the default so you can omit it) for ascending.
Post Reply