PLEASE HELP....Okay, here is a big one that is driving me nuts....I have a calendar that I want to print out events ($description) for that day right on the calendar if an event exists for that date...other variables are looked at, but the important ones that are retrieved from Mysql are $row[date] and $row[description]...if $row[date] = $cal_date then I want to print the description for that day directly on the calendar (not link to another page)....I know I still have to convert the $cal_date a little more, but I am having a really hard time getting this to work.... any help would be greatly appreciated...I have already built the admin pieces to update the database with the information, etc.
Here is the block of code that looks checks for the event on matching dates:
/*****************HELP
//checks for event
$cal_date = ($y."-".$m."-".$d);
while ($row = mysql_fetch_array($result))
{
if ($cal_date ==($row[date]))
{
print "<td class='tcell' bgcolor=#CCCCCC valign=\"top\" height=\"100\">$d<br><br>$row[description]</td>";
}
else
{
print "<td class='tcell' bgcolor=#CCCCCC valign=\"top\" height=\"100\">$d</td>";
}
}
******************************/
below is the code for the entire page (this block is about 2/3 down:
<head>
<title>Calendar</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?PHP
$Host="localhost";
$User="click";
$Password="********";
$DBName="clickdb";
$TableName="sampledaycare_classes";
$TableName2="sampledaycare_calendar";
$Link=mysql_connect($Host,$User,$Password);
mysql_select_db("clickdb");
$query_cur = "SELECT * FROM $TableName";
$result_cur = mysql_query($query_cur, $Link);
$numrows_cur = mysql_num_rows($result_cur);
$query_new = "SELECT * FROM $TableName";
$result_new = mysql_query($query_new, $Link);
$numrows_new = mysql_num_rows($result_new);
while ($row_cur = mysql_fetch_array($result_cur)){
$class_name=($row_cur[class_name]);
$teacher_name=($row_cur[teacher_name]);
$class_id=($row_cur[class_id]);
}
// Need to query by month in future to keep query size down
$select = "SELECT * FROM $TableName2 where class_id = $class_id";
$result = mysql_query($select);
$numrows = mysql_num_rows($result);
?>
<div align=center><?print ("Calendar of Events for $class_name.");?> <br>
Change Class to: <SELECT NAME="selectbox">
<option value=''>Select One
<?
while ($row_new = mysql_fetch_array($result_new))
{
echo "<option>".$row_new[class_name]."\n";
}
echo "</SELECT>";
?>
<input type=submit value="Go!">
<BR>
<hr>
<BR>
<?
mk_drawCalendar($m,$y);
?>
<?php
// Draw the Calendar
function mk_drawCalendar($m,$y)
{
if ((!$m) || (!$y))
{
$m = date("m",mktime());
$y = date("Y",mktime());
if ($m==01)
$themonth="jan";
else if ($m==02)
$themonth="feb";
else if ($m==03)
$themonth="mar";
else if ($m==04)
$themonth="apr";
else if ($m==05)
$themonth="may";
else if ($m==06)
$themonth="jun";
else if ($m==07)
$themonth="jul";
else if ($m==08)
$themonth="aug";
else if ($m==09)
$themonth="sept";
else if ($m==10)
$themonth="oct";
else if ($m==11)
$themonth="nov";
else if ($m==12)
$themonth="dec";
}
// get what weekday the first is on /
$tmpd = getdate(mktime(0,0,0,$m,1,$y));
$month = $tmpd["month"];
$firstwday= $tmpd["wday"];
$lastday = mk_getLastDayofMonth($m,$y);
?>
<table cellpadding=2 cellspacing=0 border=1>
<tr>
<td colspan=7 bgcolor="#cccc99">
<table cellpadding=0 cellspacing=0 border=0 width="100%">
<tr>
<th width="100">
<a href="<?=$SCRIPT_NAME?>?m=<?=(($m-1)<1) ? 12 : $m-1 ?>&y=<?=(($m-1)<1) ? $y-1 : $y ?>"><<</a>
</th>
<th><?="$month $y"?></th>
<th width="100">
<a href="<?=$SCRIPT_NAME?>?m=<?=(($m+1)>12) ? 1 : $m+1 ?>&y=<?=(($m+1)>12) ? $y+1 : $y ?>">>></a>
</th>
</tr>
</table>
</td>
</tr>
<tr>
<th width=100 class="tcell">Sunday</th>
<th width=100 class="tcell">Monday</th>
<th width=100 class="tcell">Tuesday </th>
<th width=100 class="tcell">Wednesday</th>
<th width=100 class="tcell">Thursday</th>
<th width=100 class="tcell">Friday</th>
<th width=100 class="tcell">Saturday</th>
</tr>
<?php
$d = 1;
$wday = $firstwday;
$firstweek = true;
//Loop Through to last day
while ( $d <= $lastday)
{
//blanks for first week
if ($firstweek) {
print "<tr>";
for ($i=1; $i<=$firstwday; $i++)
{ print "<th height=100 bgcolor=#CCCCCC> </th>"; }
$firstweek = false;
}
/*****************HELP
//checks for event
$cal_date = ($y."-".$m."-".$d);
while ($row = mysql_fetch_array($result))
{
if ($cal_date ==($row[date]))
{
print "<td class='tcell' bgcolor=#CCCCCC valign=\"top\" height=\"100\">$d<br><br>$row[description]</td>";
}
else
{
print "<td class='tcell' bgcolor=#CCCCCC valign=\"top\" height=\"100\">$d</td>";
}
}
******************************/
//Saturday end week with <tr>
// if ($wday==6) { print "<th height=150 bgcolor=#00ff00></tr>\n</th>"; }
$wday++;
$wday = $wday % 7;
$d++;
// Sunday start week with <tr>
if ($wday==0) { print "<th height=100 bgcolor=#ffffff><tr></th>"; }
//blanks for last week
if ($lastweek) {
print "<tr>";
for ($lastday=28; $tlastday<=31; $lastday++)
{ print "<th height=100 bgcolor=#AAAAAA></th> "; }
$lastweek = false;
}
}
?>
</tr></table>
<br>
<?PHP
//end calendar Draw Function
}
//Show the last day of the month
function mk_getLastDayofMonth($mon,$year)
{
for ($tday=28; $tday <= 31; $tday++)
{
$tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
if ($tdate["mon"] != $mon)
{ break; }
}
$tday--;
return $tday;
}
?>
</div>
</body>