p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Dynamic Refreshing Pages


Message #1 by "Jamal" <new_mojam@y...> on Thu, 26 Sep 2002 05:41:09
Hi Guys,
Can anyone tell me what i am doing wrongly. I want to make the background 
of my page dynamically refreshing in every 1min. I have got 3 images and 
my code is shown as below. It is not just working. Maybe my html codes are 
not in the right position.


<html><head><title>My Site</title>
<?
$images[1] = 'image1.jpg';
$images[2] = 'image2.jpg';
$images[3] = 'image3.jpg';
// keep adding more by increasting the number and adding more images
extract($_GET);
if(!isset($id)) {
   $id = 1;
} 
if($id > count($images)) {
 $id = 1;
}
$img = $images[$id];
$id++;
?>

<meta http-equiv=refresh content='300; url=index.php?id=<? print $id; ?>'>

<img src="<? print $img; ?>"></img>
Message #2 by "Gerry Vandermaesen" <gerry@a...> on Thu, 26 Sep 2002 09:34:00 +0200
Well it should work, but you will have to wait 300 secs like you
specified in the meta tag until the page get's reloaded and the $id
get's incremented. $id won't get incremented by manually refreshing the
page, maybe you got that wrong? If so you could try a different approach
for passing the $id, for example in a cookie.

-----Original Message-----
From: Jamal [mailto:new_mojam@y...] 
Sent: donderdag 26 september 2002 5:41
To: beginning php
Subject: [beginning_php] Dynamic Refreshing Pages


Hi Guys,
Can anyone tell me what i am doing wrongly. I want to make the
background 
of my page dynamically refreshing in every 1min. I have got 3 images and

my code is shown as below. It is not just working. Maybe my html codes
are 
not in the right position.


<html><head><title>My Site</title>
<?
$images[1] = 'image1.jpg';
$images[2] = 'image2.jpg';
$images[3] = 'image3.jpg';
// keep adding more by increasting the number and adding more images
extract($_GET);
if(!isset($id)) {
   $id = 1;
} 
if($id > count($images)) {
 $id = 1;
}
$img = $images[$id];
$id++;
?>

<meta http-equiv=refresh content='300; url=index.php?id=<? print $id;
?>'>

<img src="<? print $img; ?>"></img>

Message #3 by "David Scott-Bigsby" <DScott-Bigsby@P...> on Thu, 26 Sep 2002 10:03:04 -0700
Jamal,

Your code works on my site -- my only changes were $_GET to 
$HTTP_GET_VARS, as I use an older version of PHP, to use a different 
filename (img.php), and to change the time from 300 seconds to 10 
seconds.

> Can anyone tell me what i am doing wrongly. I want to make
> the background
> of my page dynamically refreshing in every 1min. I have got 3
> images and my code is shown as below. It is not just working.

So what isn't working?

(Tip: problems are easier for us to diagnose when we know the symptoms.)

dsb

***************************************       
David Scott-Bigsby
Product Manager, Web Site and PEDN

PureEdge Solutions
The Leader in Secure XML e-Forms

v:250-708-8145  f:250-708-8010
1-888-517-2675   www.PureEdge.com
***************************************
Message #4 by "David Scott-Bigsby" <DScott-Bigsby@P...> on Thu, 26 Sep 2002 10:06:02 -0700
> Can anyone tell me what i am doing wrongly. I want to make
> the background
> of my page dynamically refreshing in every 1min.

BTW, this floods my browser history with refreshes of the page. Why not 
do this in JavaScript? Then you could just change the SRC of the <IMG> 
on the client side, and only the new graphic would be downloaded. After 
all graphics were cached on the client, there would be no more downloads 
-- less work for your server!

dsb

***************************************       
David Scott-Bigsby
Product Manager, Web Site and PEDN

PureEdge Solutions
The Leader in Secure XML e-Forms

v:250-708-8145  f:250-708-8010
1-888-517-2675   www.PureEdge.com
***************************************

  Return to Index