Location: PHPKode > projects > PortalXP - Teacher Edition > PortalXP/PortalXP/calendar/welcome.php
<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, display)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, display, 'width=550,height=450,scrollbars=no');
return false;
}
//-->
</SCRIPT>

<?

	$currentday = date("j", time());
	$currentmonth = date("m", time());
	$currentyear = date("Y", time());

	$lastday = 1;
	//$database = mysql_connect($hostname, $user, $password);

	if (!isset($month))
	{
		$month = date("m", time());
		$year = date("Y", time());
	}
	

	//mysql_select_db('calendar', $database);


	$monthname = date('F', mktime(0,0,0,$month,1,$year));
	$firstday = date( 'w', mktime(0,0,0,$month,1,$year));
	while (checkdate($month,$lastday,$year))
	{
	        $lastday++;
	}      
	
	$nextmonth = $month+1;
	$nextyear = $year;
	if ($nextmonth == 13)
	{
		$nextmonth = 1;
		$nextyear = $year + 1;
	}
	$lastmonth = $month-1;
	$lastyear = $year;
	if ($lastmonth == 0)
	{
		$lastmonth = 12;
		$lastyear = $year-1;
	}

	echo "<center><table><tr>";     


	echo "<tr>";     
	echo "<td>";
        	echo "<form method=post action=calendar.php?id=$id><input type=submit value='<<'>
        	<input type=hidden name=month value=$lastmonth>
        	<input type=hidden name=year value=$lastyear></form>";
		echo "<td>";
		echo "<font size=3>$monthname</font>";
		echo "<td>";
        	echo "<form method=post action=calendar.php?id=$id><input type=submit value='>>'>
        	<input type=hidden name=month value=$nextmonth> 
        	<input type=hidden name=year value=$nextyear></form>";
	echo "</td></table>";


	echo "<table width=100% cellpadding=2 cellspacing=2 border=1>";
	echo "<tr><td width=5%><b>Sun</td><td width=18%><b>Monday</td>
		  <td width=18%><b>Tuesday</td><td width=18%><b>Wednesday</td>
		  <td width=18%><b>Thursday</td><td width=18%><b>Friday</td>
		  <td width=5%><b>Sat</td></tr>";

	for ($i=0; $i<7; $i++)
	{
		if ($i < $firstday)
		{
			echo "<td></td>";
		}
		else
		{
			$thisday = ($i+1)-$firstday;

			if ($currentyear > $year)
			{
				echo "<td valign=top bgcolor=dddddd>";
			}
			else if ($currentmonth > $month && $currentyear == $year)
			{
				echo "<td valign=top bgcolor=dddddd>";
			}
			else if ($currentmonth == $month && $currentday > $thisday && $currentyear == $year)
			{
				echo "<td valign=top bgcolor=dddddd>";
			}
			else
			{
				echo "<td valign=top bgcolor=white>";
			}
			echo "<a onClick=\"return popup(this, 'notes')\" href=calendar/display.php?day=$thisday&month=$month&year=$year&teacher_id=$id>$thisday</a><br><hr>
				<font size=2>";
			$query2 = mysql_query("SELECT subject FROM calendar WHERE stamp >= \"$year-$month-$thisday 00:00:00\" and stamp <= \"$year-$month-$thisday 23:59:59\" and teacher_id = $id ORDER BY stamp");
			for ($j = 0; $j<mysql_num_rows($query2); $j++)
			{
				$results = mysql_fetch_array($query2);
				if ($results["subject"])
				{
					echo "<font size='1'>$results[subject]</font><br><hr>";
				}
			}
			if (mysql_num_rows($query2) < 4)
			{
				for ($j=0; $j<(4-mysql_num_rows($query2)); $j++)
					echo "<br>";
			}
			echo "</td>";
		}
	}

	echo "</tr>\n";
	$nextday = ($i+1)-$firstday;

	for ($j = 0; $j<5; $j++)
	{
		echo "<tr>";
		for ($k = 0; $k<7; $k++)
		{
			if ($nextday < $lastday)
			{
				if ($currentyear > $year)
                                {       
                                        echo "<td valign=top bgcolor=dddddd>";
                                }
				else if ($currentmonth > $month && $currentyear == $year)
                        	{       
                               		echo "<td valign=top bgcolor=dddddd>";
                        	}               
                        	else if ($currentmonth == $month && $currentday > $nextday && $currentyear == $year)
                        	{
                                	echo "<td valign=top bgcolor=dddddd>";
                        	}
                        	else    
                        	{
                               		echo "<td valign=top bgcolor=white>";
                        	}
				echo "<a onClick=\"return popup(this, 'notes')\" href=calendar/display.php?day=$nextday&month=$month&year=$year&teacher_id=$id>$nextday</a><br><hr>
					<font size=2>";
				$query3 = mysql_query("SELECT subject FROM calendar WHERE stamp >= \"$year-$month-$nextday 00:00:00\" AND stamp <= \"$year-$month-$nextday 23:59:59\" and teacher_id = $id ORDER BY stamp");
				for ($i = 0; $i<mysql_num_rows($query3)+4; $i++)
				{
					$results2 = mysql_fetch_array($query3);
					if ($results2["subject"])
					{
						echo "<font size='1'>$results2[subject]</font><br><hr>";
					}
					else if ($i < 4)
					{
						echo "<br>";
					}
				}
				echo "</td>";
				$nextday++;
			}
		}
		echo "</tr>\n";
	}

	echo "</table>";


?>
Return current item: PortalXP - Teacher Edition