I am not hoping for fully working examples, I am just in need for a direction to start.
So to explain what I am trying to do, I have an app where users log in, log out, add content, do actions in the site etc. I want to know if it is possible using PHP and AJAX to make a widget that auto updates like this:
- Someone logged in…
- Someone added photo…
- etc..
I just want a guideline or direction to follow, how would I make real-time widget that auto updates and pull data/actions/etc.. would it be time interval update?
Any ideas?
First of all you need to store a list of actions that you want displayed in the widget, for example you can create a database table with (id, created_at, action_description) and whenever a user performs an action that should be displayed in the widget (e.g uploaded a photo, etc), insert a record in that table (note this is not very efficient and does not scale well if you have many users)
Second, on the browser side, you periodically call a function (with setInterval for example) to query the server for updates and update the widget
The above solution is very simplistic and wont scale.
Hope that helps