Web Content Display Realtime at a Time Database Updated

Javascript coding ..

Moderators: macek, egami, gesf

HeldiL
New php-forum User
New php-forum User
Posts: 1
Joined: Sat Feb 04, 2012 2:01 pm

Web Content Display Realtime at a Time Database Updated

Postby HeldiL » Sat Feb 04, 2012 2:04 pm

Good morning all,
I am a beginner with PHP's dn JS, I want to ask about how to create the look of the website whose content changes in real time when the database is updated, so the client does not need to refresh to see new data entered in the database. I really find it helpful if the explanation is accompanied with source code ..
I'm using PHP 4 and Mysql.

If this topic has been discussed before breathing I apologize. Thank you for your answer. :)

User avatar
JordanMRichards
New php-forum User
New php-forum User
Posts: 84
Joined: Mon Apr 23, 2012 7:43 am
Contact:

Re: Web Content Display Realtime at a Time Database Updated

Postby JordanMRichards » Fri Apr 27, 2012 7:49 am

I really want to know this too

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

Re: Web Content Display Realtime at a Time Database Updated

Postby minimihi » 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.

Update:
!!! 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.


Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 1 guest

cron