views:

850

answers:

3

Hi 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 dont want users refreshing to see the changes... is there any way to refresh the included file every 3 minutes for example?

Thanks!

+3  A: 

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 :

Pascal MARTIN
+1 I, somehow, didn't know about the Ajax.PeriodicalUpdater. Very handy.
Mark Biek
Yah thanks, i thought about this - i just couldn't be bothered to include jQuery :D
tarnfeld
If the only "advanced javascript" thing you need is a couple of Ajax Request, jQuery is probably a bit overkill/oversized, indeed ^^
Pascal MARTIN
A: 

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

A: 

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.

wyrmmage