Page 1 of 1

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

Posted: Wed Feb 04, 2009 1:41 pm
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

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

Posted: Wed Feb 04, 2009 1:44 pm
by Benjamin
Can you post your code?

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

Posted: Wed Feb 04, 2009 1:45 pm
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.

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

Posted: Wed Feb 04, 2009 4:19 pm
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.

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

Posted: Wed Feb 04, 2009 5:07 pm
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.

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

Posted: Wed Feb 04, 2009 7:15 pm
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?

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

Posted: Mon Feb 09, 2009 12:11 am
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.