i have a php script which writ开发者_JAVA技巧es data to a file every 5 seconds and have a second php script that opens the file and then queries a database based on the value in that file..
so to display the result of the query i need to run the php script on my browser..since the data in the file keeps changing,so the result of the query will also keep changing,but i can see the new result only when i refresh the browser..
I want a way in which i can see the new result of the query without refreshing the browser.. i am new to this so i hope i explained my problem to my best..waiting for a solution..thanks
You'll need to use some AJAX function to retrieve the data, and then Javascript to update the browser. Check out http://api.jquery.com/jQuery.ajax for a good place to start.
this will automatically refresh the page for every 5secs
header( "refresh:5;url=page url link" );
Example :
header( "refresh:5;url=http://localhost/incedx.php" );
You might wanna look at
How to update content based on user actions [like the facebook wall]
And you do not need to "i have a php script which writes data to a file every 5 seconds and have a second php script that opens the file and then queries a database based on the value in that file.."
Write a JavaScript function and call it on load of page setInterval for that function so it is called after an interval of time in that function write ajax call to page which executes your query and return the values.
setinterval("test()" ,1000);
function test(){
//ajax call to php page
}
精彩评论