Jump to content

Auto-Updating Feed


Recommended Posts

  • Administrators

I'm trying to find a good tutorial on how to create a spot on my website that will pull in data from a mysql table and auto update without reloading the page. Something very similar to the funtionality of Facebook's News Feed. I can't seem to find anything. Anyone know of any good tutorial on how to accomplish this in PHP?

Link to comment
Share on other sites

Its just basic AJAX.


So at the front end you use js via ajax to pull the data and then render it.


At the back end you just return the data from mysql query.


I'll post later some code examples if you want.

Edited by __Darknite
Link to comment
Share on other sites

  • Administrators

Yes please do, I would even be fine just refreshing a div, but having issues getting it done.


Trying to do it with this example: http://www.brightcherry.co.uk/scribbles/jquery-auto-refresh-div-every-x-seconds/


But it just continues to return random numbers that refresh.

Link to comment
Share on other sites

  • Administrators

I got it!


Ended up using this tutorial, made it real simple. You just keep the portion that needs refreshed in your response.php file and then html in you main .php file that the user hits.


This is the javascript code that you put in the beginning of the page:

$(document).ready(function() {
var refreshId = setInterval(function() {
}, 9000);$.ajaxSetup({ cache: false });



This div is in your main .php file the user goes to wherever you want to put it, it will be the div that is refreshed

<div id="responsecontainer">


Now after you have that setup, just drop your code you need to be refreshed in your response.php file and wala!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...