Connecting Tech Pros Worldwide Forums | Help | Site Map

how to refresh my page every ten seconds?

Newbie
 
Join Date: Mar 2008
Posts: 3
#1: Mar 4 '08
can someone help me with code to refresh my PHP pages every ten seconds?

ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Mar 4 '08

re: how to refresh my page every ten seconds?


Quote:

Originally Posted by Hemavathi

can someone help me with code to refresh my PHP pages every ten seconds?

There are no PHP pages, just HTML pages, 'constructed' by PHP and send to the client.

You could use statement
Expand|Select|Wrap|Line Numbers
  1. <meta http-equiv="refresh" content="10">
at the top of your html page.

This is a HTML and (maybe later) JavaScript question, so I will move it to that form.
hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,609
#3: Mar 4 '08

re: how to refresh my page every ten seconds?


Quote:

Originally Posted by Hemavathi

can someone help me with code to refresh my PHP pages every ten seconds?

Either use the meta tag[html]<meta http-equiv="refresh" content="10" />
<meta http-equiv="cache-control" content="no-cache" />[/html]Or use setTimeout to call a function which refreshes your page.
Expand|Select|Wrap|Line Numbers
  1. function refreshAfter10() {
  2.     window.setTimeout("refreshPage()",10000); //10000micro sec = 10 sec
  3. }
  4. function refreshPage() {
  5.     window.location.replace('http://www.yoursite.com');
  6. }
Call refreshAfter10() onload of body.
Newbie
 
Join Date: Mar 2008
Posts: 3
#4: Mar 4 '08

re: how to refresh my page every ten seconds?


[quote=hsriat]Either use the meta tag[html]<meta http-equiv="refresh" content="10" />
<meta http-equiv="cache-control" content="no-cache" />[/html]Or use setTimeout to call a function which refreshes your page.
Expand|Select|Wrap|Line Numbers
  1. function refreshAfter10() {
  2.     window.setTimeout("refreshPage()",10000); //10000micro sec = 10 sec
  3. }
  4. function refreshPage() {
  5.     window.location.replace('http://www.yoursite.com');
  6. }
Call refreshAfter10() onload of body.[/QUOte

How could I check whether it is refreshed?????
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#5: Mar 4 '08

re: how to refresh my page every ten seconds?


Quote:

Originally Posted by Hemavathi

How could I check whether it is refreshed?????

Display your screen and see it flicker every 10 seconds. How else do you suggest you can/want to check that?

Ronald
hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,609
#6: Mar 4 '08

re: how to refresh my page every ten seconds?


Quote:

Originally Posted by ronverdonk

Display your screen and see it flicker every 10 seconds. How else do you suggest you can/want to check that?

Ronald

I think that the refresh goes too fast that she's not able to find out if its refreshed.

@Hemavathi
Add alert('I\'m Refreshed'); in the onload of the body. And see if its displayed after 10 sec.
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#7: Mar 4 '08

re: how to refresh my page every ten seconds?


My screen is probably too slow. I notice a refresh being done. Time to buy a faster one.

Ronald
hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,609
#8: Mar 4 '08

re: how to refresh my page every ten seconds?


Quote:

Originally Posted by ronverdonk

My screen is probably too slow. I notice a refresh being done. Time to buy a faster one.

Ronald

:D
Even mine is not that fast. I just guessed that may be her screen is, along with her server.
Newbie
 
Join Date: Mar 2008
Posts: 10
#9: Mar 5 '08

re: how to refresh my page every ten seconds?


is thr any equivalent statement in php to refresh the content like meta tag(<meta http-equiv="refresh" content="10">) in HTML?
Newbie
 
Join Date: Mar 2008
Posts: 3
#10: Mar 5 '08

re: how to refresh my page every ten seconds?


yeah i too look for the same....
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#11: Mar 5 '08

re: how to refresh my page every ten seconds?


Quote:

Originally Posted by susee

is thr any equivalent statement in php to refresh the content like meta tag(<meta http-equiv="refresh" content="10">) in HTML?

Not really. PHP is a server side language, HTML and JavaScript run client side. And the latter has to be refreshed. So if you could force PHP to send a new HTML page to the client, you could. But I'd stick with HTML/JavaScript solution if I were you.

Ronald
Newbie
 
Join Date: Mar 2008
Posts: 10
#12: Mar 5 '08

re: how to refresh my page every ten seconds?


Quote:

Originally Posted by ronverdonk

Not really. PHP is a server side language, HTML and JavaScript run client side. And the latter has to be refreshed. So if you could force PHP to send a new HTML page to the client, you could. But I'd stick with HTML/JavaScript solution if I were you.

Ronald

Let me explain in detail, I ve a HTML page in which I display some values reading from an XML which change dynamically.I have used PHP to read from the xml. Now my problem is to get the xml entries whenever i refresh my page. How can i do this?
hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,609
#13: Mar 5 '08

re: how to refresh my page every ten seconds?


Quote:

Originally Posted by susee

Let me explain in detail, I ve a HTML page in which I display some values reading from an XML which change dynamically.I have used PHP to read from the xml. Now my problem is to get the xml entries whenever i refresh my page. How can i do this?

Please tell in details how are you doing it... with some code.
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#14: Mar 5 '08

re: how to refresh my page every ten seconds?


Quote:
Let me explain in detail, I ve a HTML page in which I display some values reading from an XML which change dynamically.I have used PHP to read from the xml. Now my problem is to get the xml entries whenever i refresh my page. How can i do this?
You are not talking about an RSS feed, are you?

Ronald
Newbie
 
Join Date: Mar 2008
Posts: 10
#15: Mar 6 '08

re: how to refresh my page every ten seconds?


Quote:

Originally Posted by ronverdonk

You are not talking about an RSS feed, are you?

Ronald


may be similar to that. Help me out in tis...
Newbie
 
Join Date: Mar 2008
Posts: 1
#16: Mar 6 '08

re: how to refresh my page every ten seconds?


If possible, do not use the javascript method. Some people block the javascript on their browser.
Newbie
 
Join Date: Mar 2008
Posts: 10
#17: Mar 6 '08

re: how to refresh my page every ten seconds?


hi
i have a php script inside html.i used <meta http-equiv="refresh" content="10"> in the body of the page,the page is getting refreshed but the php script is not getting refreshed to get the updated data.so guys pls tel us the exact solution for getting the refreshed data.for this we need a php statements to refresh.
i think am quite clear now.
Reply