Dispaly Events
All,
I am trying to display a calendear and then select an event from the db and change the shading of the calendar block if there is an event in the db. I am having troube displaying the events on teh calendar though. Here is the code I am trying to use. It only changes the color for one block but there are multiple events. I'm not sure how to get it to work for all the events.
if(isset($prm) and $prm > 0){
$m=$prm+$chm;}else{
$m= date("m");}
$d= date("d"); // Finds today's date
$y= date("Y"); // Finds today's year
$no_of_days = date('t',mktime(0,0,0,$m,$d,$y)); // This is to calculate number of days in a month
$mn=date('M',mktime(0,0,0,$m,$d,$y)); // Month is calculated to display at the top of the calendar
$yn=date('Y',mktime(0,0,0,$m,$d,$y)); // Year is calculated to display at the top of the calendar
$j= date('w',mktime(0,0,0,$m,1,$y)); // This will calculate the week day of the first day of the month
for($k=1; $k<=$j; $k++){ // Adjustment of date starting
$adj .="<td> </td>";
}
/// Starting of top line showing name of the days of the week
echo " <table border='1' bordercolor='#FFFF00' cellspacing='0' cellpadding='0' align=center>
<tr><td>";
echo "<table cellspacing='0' cellpadding='0' align=center width='100' border='1'><td align=center bgcolor='#ffff00'><font size='3' face='Tahoma'> <a href='php_calendar.php?prm=$m&chm=-1'><</a> </td><td colspan=5 align=center bgcolor='#ffff00'><font size='3' face='Tahoma'>$mn $yn </td><td align=center bgcolor='#ffff00'><font size='3' face='Tahoma'> <a href='php_calendar.php?prm=$m&chm=1'>></a> </td></tr><tr>";
echo "<td><font size='3' face='Tahoma'><b>Sun</b></font></td><td><font size='3' face='Tahoma'><b>Mon</b></font></td><td><font size='3' face='Tahoma'><b>Tue</b></font></td><td><font size='3' face='Tahoma'><b>Wed</b></font></td><td><font size='3' face='Tahoma'><b>Thu</b></font></td><td><font size='3' face='Tahoma'><b>Fri</b></font></td><td><font size='3' face='Tahoma'><b>Sat</b></font></td></tr><tr>";
////// End of the top line showing name of the days of the week//////////
//////// Starting of the days/////////
$query = "Select date from events where id='1'";
$result = mysql_query($query);
$resultset = mysql_fetch_array($result);
for($i=1;$i<=$no_of_days;$i++){
$date = "$mn/$i/$yn";
if ($date == $resultset[date]){
echo $adj."<td valign=top bgcolor="CCCCCC"><font size='2' face='Tahoma'>$i<br>";
echo "</font></td>";
}else{
echo $adj."<td valign=top><font size='2' face='Tahoma'>$i<br>";
echo "</font></td>";
}
$adj='';
$j ++;
if($j==7){echo "</tr><tr>";
$j=0;}
}
echo "</tr></table></td></tr></table>";
Any help is appreciated. Thanks