Web Content Display Realtime at a Time Database Updated

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply
User avatar
New php-forum User
New php-forum User
Posts: 81
Joined: Mon Apr 23, 2012 7:43 am

Fri Apr 27, 2012 7:49 am

I really want to know this too

User avatar
New php-forum User
New php-forum User
Posts: 236
Joined: Sat Apr 14, 2012 11:57 am
Location: Vilnius, Lithuania

Sat Apr 28, 2012 9:22 am

You could log any changes to database in separate table.
When user visits a page, make a call to PHP file via AJAX in chosen time interval.
PHP file would check logs table (better check only parts which are relevant to page user sees). If anything changed on that table , generate new content and send it back to replace old content. When old content is replaced with new, you should update logs table with indicator which would show that this update is no longer new.

If anyone has a better (or any) option, I would like to hear it as well.

!!! This way only single user would get updates, other ones, who are browsing a page, wouldn't see update as new one and wouldn't generate new content.

That's why there is a need to store information about, for example, latest updates user is seeing in session.
That way we could get rid of indicator which would show if update is new and only check if there are newer updates compared to ones stored in user session.
To make it easier, a date/time of when page was loaded/updated should be stored in session, which would help to get rid of all old updates.

Saving date/time in session and date/time of update of database would also bring another option of how to check for new updates. And that would be even easier than everything I said so far.

Post Reply