OK, im trying to develope an event calendar. So, far i have used only php. I am new to programming and thats the only language i have learned atm. anyway, when i click the next or prev month buttons it sets cookies for new months etc.. to a cookie.php from index.php. Inadex.php has an iframe displying main.php which uses fopen, fread etc to read txt files back containing the events. the prob is when i select a diff month it sets cookies and refreshes back to index w new month info, but the iframe isnt getting the new month info because its not being reloaded. Need some way to reload the iframe page once index gets the new variables from cookie.php. im not aware of a php refresh command script, so maybe theres some js to do this im not sure. any way heres my 3 pages im referring to:
here is my index.php"
<?php include("includes/header.php");?>
<?php include("includes/calendar1.php"); ?>
<div id= "side_page">
<iframe src= "includes/main.php" height= "600px" width= "350px" name= "side_page" ></iframe>
</div>
here is the calendar1.php"
<?php
ini_set('date.timezone', 'America/Indiana/Knox');
$date = time();
$day = date('j', $date);
$month = date('m', $date);
$mon = date('M', $date);
$year = date('Y', $date);
if (isset($_COOKIE["month"])){
$month=$_COOKIE["month"];
}
if (isset($_COOKIE["mon"])){
$mon=$_COOKIE["mon"];
}
if (isset($_COOKIE["year"])){
$year=$_COOKIE["year"];
}
$prevmon= $mon;
$prevy= $year;
$prevm= $month -1;
if($prevm <1){
$prevm = 12;
$prevmon= 12;
$prevy = $year-1;
}
$nextmon= $mon;
$nexty = $year;
$nextm = $month+1;
if($nextm >12){
$nextm = 1;
$nextmon= 1;
$nexty = $year+1;
}
$first_day = mktime(0,0,0,$month, 1, $year);
$title = date('F', $first_day);
$day_of_week = date('D', $first_day);
switch($day_of_week){
case "Sun": $blank= 0; break;
case "Mon": $blank= 1; break;
case "Tue": $blank= 2; break;
case "Wed": $blank= 3; break;
case "Thu": $blank= 4; break;
case "Fri": $blank= 5; break;
case "Sat": $blank= 6; break;
}
$days_in_month = cal_days_in_month(0, $month, $year);
echo "<div id =\"calendar\"><table border= \"0\" width= \"500\" height= \"600\">";
echo "<tr>
<td colspan=\"1\">
<a href=\"cal_cook.php?m=$prevm&y=$prevy&mon=$prevmon\"><span title= \"Previous Month\"><<</span></a></td>
<td colspan= \"5\" id=\"calhead\">$title $year</td>
<td colspan= \"1\"><a href=\"cal_cook.php?m=$nextm&y=$nexty&mon=$nextmon\"><span title= \"Next Month\">>></span></a></td>
</tr>";
echo "<tr>
<td width= \"42\">S</td>
<td width= \"42\">M</td>
<td width= \"42\">T</td>
<td width= \"42\">W</td>
<td width= \"42\">T</td>
<td width= \"42\">F</td>
<td width= \"42\">S</td>
</tr>";
$day_count = 1;
while($blank > 0){
echo "<td> </td>";
$blank = $blank -1;
$day_count++;
}
$day_num = 1;
$first_of_month= mktime(0,0,0,$month, 1, $year);
$days= date('l', $first_of_month) ;
while($day_num <= $days_in_month){
if($day==$day_num){
echo "<td><span style= \"font-size: 35px; font-weight:bold; color:#ffffff;\" title = \"Today\"><a href=\"includes/";
if($month== date(m)){
Echo "main.php";
}else{
$blank= "No events to display";
echo "main.php";
}
echo "?day=$days&mon=$mon&num=$day_num&t=$title&b=$blank&m=$month\" target= \"side_page\">$day_num</a></span></td>";
}else{
echo "<td><a href=\"includes/";
if($month== date(m)){
echo "main.php";
}else{
$blank= "No events to display";
echo "main.php";
}
echo "?day=$days&mon=$mon&num=$day_num&t=$title&b=$blank&m=$month\" target=\"side_page\">$day_num</a></td>";
}
$day_num++;
$day_count++;
$days= date('l', $first_of_month+=86400);
if($day_count > 7){
echo "</tr><tr>";
$day_count=1;
}
}
while($day_count >1 && $day_count <=7)
{
echo "<td> </td>";
$day_count++;
}
echo "</tr></table></div>";
?>
here is the iframe page:
<?php
/*///////////////////////Introduction Heading///////////////////////////////////////////////////////////////////////////*/
if(!isset($_GET['day'])){ //default view, if no day has been selected. defaults to todays events. manual var set since no-
$date= time(); //"GET" has been sent yet
$day_num= date("j",$date); //ex.1-31 day number
$month= date("F", $date); //ex. October
$day= date("l", $date); //ex. Sunday
echo "<h3>Todays events:</h3>";
}else{ // if a day "HAS" been selected, var's will be available via "GET"
$day_num= $_GET['num']; //ex.1-31 day number
$month= $_GET['t']; //ex. October
$day= $_GET['day']; //ex. Sunday
echo "<h3>Events for ";
echo $day .", " . $month . " " . $day_num ."</h3>";
}
/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
?>
<?php
$my_file= "appointment_" . $day_num . ".txt";
$folder= $month;
$fh= fopen("$folder/$my_file", 'r');
$read= fread($fh, 500);
$array= explode(".", $read);
foreach($array as $event){
echo $event . "<br /><hr /><br />";
}
fclose($fh);
?>
<a href= "" >View Events for October</a>
here is my cookie page cal_cook.php:
<?php
// Write the current month and year into cookies and return back to index.php
$month=$_GET['m'];
$mon=$_GET['mon'];
$year=$_GET['y'];
setcookie("month", $month, time()+604800);
setcookie("mon", $mon, time()+604800);
setcookie("year", $year, time()+604800);
header ("location: index.php");
?>
any help would be greatly appreciated