Refreshing new content.
Posted: Thu Jul 16, 2009 8:10 am
Hi I am currently working on a php script that should pull dates and events from a Microsoft access database. Everything works fine, but I am stuck on a problem. The screen that displays the meetings is the screen int he entrance hall, so it cannot be scrolled if more then 9 meetings are displayed. The page should refresh every 20 seconds if theres more then 9 meetings it should refresh with the next content and also in both cases at the end of 20 seconds it should refresh with displaying a french version of the same content. So it's kind of in a loop, that refreshes every 20 seconds going through all the english content and then going through the french then back to english, and so forth.
Anyone has any idea how can i do this? I tried several things but it doesn't work. If I put a refresh call in the header it just refreshes the same page.
this is the code i currently have.
Anyone has any idea how can i do this? I tried several things but it doesn't work. If I put a refresh call in the header it just refreshes the same page.
Code: Select all
<?php
//header( 'refresh: 60; ' );
date_default_timezone_set("America/Montreal");
$i = 1;
$bool = true;
$count = 1;
$content_block = "
<html>
<head>
<meta http-equiv=\"content-type\" content=\"text/html; charset= iso-8859-1\">
<title>Meeting Display System</title>
</head>
<body background=\"background.jpg\" text=\"#006699\" link=\"#0000ff\" vlink=\"#ff00ff\" rightmargin=0>
<BR>
<TABLE>
<TR><TD width=100 valign=top><CENTER><IMG height=65 src=\"cummings3.jpg\" width=75 ></CENTER></TD>
<TD width=320><CENTER><FONT face=\"Book Antiqua\" color=\"#F3F49C\" size = 6><I>
Maison Cummings House</I></FONT></CENTER></TD><TD><CENTER>
<FONT face=\"Book Antiqua\" color=\"#F3F49C\" size=3>". date("l, F d, Y")."</FONT><BR>
<FONT face=\"Book Antiqua\" color=\"#F3F49C\" size=5><CENTER>". date("h:i A")."</CENTER></FONT></CENTER></TD></TR></TABLE>
<TABLE border= 1 bordercolor=black><TR><TD><center>
<font size=5.5 color=black><B><U>Time</B></font></center></U></TD><td width=500>
<center><font size=5 color=black><B><U>Meeting</B></font></center></U></td>
<TD width=200><font size=5 color=black><B><U>Room</B></font><CENTER></CENTER></U></TD></TR>";
$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
// Microsoft Access connection string.
$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\\Inetpub\\wwwroot\\MeetingSystemTest\\Meetingsystem\\meeting.mdb");
$rs = $conn->Execute("SELECT Time, Meeting, Room, Date FROM Event WHERE Date Like '%" .date("n/d/Y"). "%' ORDER BY Time");
while (!$rs->EOF)
{
$time = strtotime($rs->Fields('Date') . ' ' . $rs->Fields('Time'));
$timedisp = strtotime($rs->Fields("Time")->Value);
if ($time > time())
{
$count = $count + 1;
if($i == 1)
{
$i = $i + 1;
$content_block .="<TR bgcolor=#FFFFFF><TD><Font color=black><Center>
<font size=4 face=Arial>".date("H:i",$timedisp).
"</TD><TD><Font color=black size=4 face=Arial> "
.$rs->Fields("Meeting")->Value."</TD><TD>
<Font color=black size=4 face=Arial>".$rs->Fields("Room")->Value."</TD</TR>";
}
else
{
$i = $i - 1;
$content_block .= "<TR bgcolor=#3E797D><TD><Font color=black><Center>
<Font size=4 face=Arial>".date("H:i",$timedisp).
"</TD><TD><Font color=black size=4 face=Arial> "
.$rs->Fields("Meeting")->Value."</TD><TD>
<Font color=black size=4 face=Arial>".$rs->Fields("Room")->Value."</TD</TR>";
}
}
$rs->MoveNext();
}
for($x = $count; $x <= 9; $x++)
{
if($i==1)
{
$i = $i + 1;
$content_block .= "<TR bgcolor=#FFFFFF><TD><Font color=black><Center>
<Font size=4 face=Arial>
</TD><TD><Font color=black size=4 face=Arial> </TD><TD>
<Font color=black size=4 face=Arial> </TD</TR>";
}
else
{
$i=$i-1;
$content_block .= "<TR bgcolor=#3E797D><TD><Font color=black><Center>
<Font size=4 face=Arial>
</TD><TD><Font color=black size=4 face=Arial> </TD><TD>
<Font color=black size=4 face=Arial> </TD</TR>";
}
}
$rs->Close();
$content_block .= "</table></body></html>";
header("refresh: 20;location:phptest.php?$content_block");
?>