news ticker similar to facebook in php

1k views Asked by At

I want to create a live news ticker similar to facebook in functionality.

I have already created a page where it will be having the news ticker ... Also, the database is ready to have the data ... What I don't know how to do is the rotation of the ticker as soon as new news have been added to the database ... I can do it when the page refreshes ... but I can't have it done live ... I wish somebody help me.

I have everything ready to be published, but waiting for the news-ticker ...

NOTE: I have only psudo-code no php finished yet.

3

There are 3 answers

5
Aleks G On

You probably want to use timed AJAX calls. For example, every 1 minute send a request to the server to see if anything new is added. If yes, then display the new piece of news to replace the currently displayed one.

2
Evert On

You'll need some kind of ajax-mechanism.

You can either poll a url every x seconds to see if there's any updates, you if you really want real-time, you'll need something like nodejs on the server (or anything that's not as cgi-like as PHP).

But if you want to keep things simple, I'd start with a simple Ajax solution and polling every x seconds.

0
dimitril On

I would suggest doing it with AJAX, poll the database once every 30 seconds for new entries.

AJAX let's you communciate asynchronously with the server, this way you can get new data without a page refresh.