Hello,
I need to build a website that updates in real time, but I do not know what the best way to implement a solution that will allow me to do this. I have a program which constantly checks for new pricing data from an exchange and then writes this data to a mysql table. I would like to build a website which will display this data and be up to date. Ideally any new data would be 'pushed' and immediately reflected on the website but I would also settle for a slightly less ideal solution if it's significantly easier to implement. Can anyone suggest how I should go about solving this problem and what tools (php, javascript, ...) would be best applicable for each part?
Thanks,
Max
Real-time updating website
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Real-time updating website
If the data is in MySQL then all you need to do is fetch it with PHP and generate HTML to send to the browser. Check the manual for PDO for code examples.
You may want to investigate setting the HTTP headers so the page(s) are not cached by the browser. That way users get the latest data.
You may want to investigate setting the HTTP headers so the page(s) are not cached by the browser. That way users get the latest data.
(#10850)
Re: Real-time updating website
I wonder if Max doesn't mean a real-time updating after the page has been loaded into the browser. In that case, he needs to use AJAX and a Javascript loop that refreshes the data at a specified interval (seconds, or minutes, or whatever).
Re: Real-time updating website
( or just put a meta refresh tag in your html header)
Re: Real-time updating website
that's not really real-timejosh wrote:( or just put a meta refresh tag in your html header)
Re: Real-time updating website
Why isn't it? If you put a 1 second refresh time, I'd call it pretty close.arjan.top wrote:that's not really real-timejosh wrote:( or just put a meta refresh tag in your html header)
Re: Real-time updating website
Neither is ajax, the client has to post a request to the server, an electrical signal leaves the client computer and goes halfway around the globe and back, plus factor in the time it takes the client computer to process the ajax response. Even "live" tv is not really live, not even close.arjan.top wrote:that's not really real-time
Ajax is the same thing from the user's opinion. Unless the surrounding XHTML is heavy weight. Easy solution: iframe
But yeah ajax wouldn't be a bad way to do it though.
Re: Real-time updating website
did not say ajax is real-time (but hame some tricks to get almost real-time)
comet (ajax push, HTTP streaming, server push or. any other name) is the closest to real-time we can do right now (WebSocket should solve that)
the idea is that server dows push the data to the client when it is avaliable
comet (ajax push, HTTP streaming, server push or. any other name) is the closest to real-time we can do right now (WebSocket should solve that)
the idea is that server dows push the data to the client when it is avaliable