Search code examples
phpajaxurlauto-update

Want to requery a url and get fresh value which is assigned to a variable in php every few seconds


I have a query which I make to get live prices.. and the value is assigned to a variable.... I want to refresh that query say every 5 seconds and automatically assign the returned value to the variable... so if the variable is called by repeatedly I get new values... in PHP

$requestUrl = http://mmm.com?c=sss;

returns me a value.. which I assign to $price

so when I call $price say every 5 sec it should return fresh values...

Meaning the request url should be run say every 5 sec and values assigned every 5 sec...

Pls guide...


Solution

  • Try this post which is an excellent guide on how to achieve this - How to Refresh/Reload Page or Part of the Page Automatically. It show a full meta refresh using specified time or a partial refresh. Another good example on how to do this - Auto refresh webpage every 5 second with PHP,HTML and JavaScript