What is the simplist way to reload a page every 5 seconds, in PHP?
reload page
<meta http-equiv="refresh" content="5;url=samepage.php">
is there any way to reload someone elses page every 5 seconds?
Originally posted by drag0n
is there any way to reload someone elses page every 5 seconds?
Go over and press F5 on their keyboard a few times?
how do you make it reload automatically without you haveing o press F5
Errr.... you don't - or if your really good then maybe mind control!
If you give a bit more information then maybe we could give you slightly more coherent answers.
Well, lets say there is a page that updates very frequently and I want to make another site that just reloads that page every so many seconds to display the newly updated version. Is there any way to do that?
if(!empty($_GET))
{
if($_GET["act"] != "refreshed")
{
echo "<meta http-equiv=\"refresh\" content=\"5;url=page.php?act=refreshed\">";
}
}
is that what your looking for ?
Ok - lemme get this straight.
A user opens your script on their machine in a browser window, and you want to refresh a page in another browser window on the same machine?
Well - there are 2 answers as to whether this is possible. One is yes and one is no.
TBH - this isn't a PHP problem since this seems to based around a client side solution, but I will see if I can't point you in the right direction anyhow.
The 2 reasons for it being possible or not are:
Yes - only if the instance of IE you are running in is the same instance as the other site you are trying to refresh. Just run some Javascript along the lines of "windowref.reload();" where "windowref" is a JS reference to the window you are interested in running. If you set a standard JS timeout to occur every 5 seconds and run that then you whould be fine.
No - if you have different instance of IE (i.e. your page is not responsible for opening the window of the other site). Because of security issues in a browser, it is not possible for you to access any other browser window, in the same way that you aren't allowed to access any other processes or files on the client machine.
Anyhow - hope I am on the right lines.
so for the url, i can replace it with the url of any page i want, for example:
http://www.thispage.com/reload/reload.php?id=6
Use frames and JavaScript or grab the other page's data with PHP and refresh that every 5 seconds.
The server-admin might not be too happy with you if you're leeching a lot of their bandwidth.
explain more please, that sounds like a good idea, maybe you could show me an example? Thanks
Here's a script I did just to see if it would work.
http://www.causefx.com/weather.html
<?
$city = "Salt Lake City";
$state = "UT";
$goodcity = strtolower(str_replace(" ", "+", $city));
$weatherurl = "http://rain.advance.net/index.ssf?%24%24ZIPCITY=$goodcity%2C+$location[state]";
$page = implode('', file($weatherurl));
if (stristr($page, "<BLOCKQUOTE>")) {
echo "no weather";
} else {
$parseweather = stristr($page, "<BR><FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"2\"><B>CURRENT CONDITIONS</b>");
$weather = substr($parseweather, 0, strpos($parseweather, "<table width=470 cellspacing=0 cellpadding=0 border=0>"));
$weather2 = str_replace("<FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"3\" COLOR=\"#0099CC\">", "<FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"3\" COLOR=\"#$citycolor\">", $weather);
echo "<blockquote>";
echo "<hr width=660 noshade align=left color=#344771>\n";
echo $city.", ".$state;
echo "<table width=467 cellpadding=0 cellspacing=0 border=0>\n";
echo "<tr>\n";
echo "<td>";
echo $weather2;
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</blockquote>";
}
?>
Through a meta refresh in there and it should work fine