tarnfeld
tarnfeld

Reputation: 26566

Refresh PHP include()

What is the best way to refresh the content of a var that is included? For example, I have this code:

<marquee>
     <?php
          include('note.php');
     ?>
</marquee>

This is great, as I can show on the page the contents of note.php. Say I change note.php but I don't want users refreshing to see the changes...is there any way to refresh the included file every 3 minutes for example?

Upvotes: 4

Views: 7991

Answers (3)

neoncube
neoncube

Reputation: 83

Unless you just want to put some javascript in to refresh the page every three minutes, you'll need to look into another technology, namely AJAX. As far as I know, PHP can not do this alone.

Upvotes: 0

jason
jason

Reputation:

Only by using an ajax like call.. take a look at prototype or jquery for decent JS libraries to help with this..

Upvotes: 0

Pascal MARTIN
Pascal MARTIN

Reputation: 401172

To refresh only a portion of a page, you'll have to use some kind of Ajax Request : once the page has been sent to the browser, the server has done it's job, and cannot modify is anymore : the request of fetching a new portion of the page as to come from the browser.

You could do some Ajax requesting "by hand", it's not that hard ; but I'd rather suggest that you take a look at some of the great javascript frameworks that exists out there -- that might be helpful in the future, when adding more functionnalities to your application.

For instance :

Upvotes: 5

Related Questions