I have a calendar script that when ran, querys a database to see if any events exist, if any do, it should BOLD the font of the date associated with the date entry in the database. The code works, except for bolding of the font. I cannot figure out how to change the bolding of the font. Any ideas?
Below is the code:
The problem portion of the code starts at line 103 and continues to line 110. Basically, if the date has any events at all it should bold the date - simple as that. It does display the date but doesn't change the font-weight.
This script is getting called as part of a AJAX app too if that is helpful any.
Below is the code:
Code:
<?php
//Check if the month and year values exist
if ((!$_GET['month']) && (!$_GET['year'])) {
$month = date ("n");
$year = date ("Y");
} else {
$month = $_GET['month'];
$year = $_GET['year'];
}
if($month==12) {
$next=1;
$nexty=$year + 1;
} else {
$next=$month + 1;
$nexty=$year;
}
if($month==1) {
$prev=12;
$prevy=$year - 1;
} else {
$prev=$month - 1;
$prevy=$year;
}
$currentmonth = date("m");
$currentyear = date("Y");
//Calculate the viewed month
$timestamp = mktime (0, 0, 0, $month, 1, $year);
$monthname = date("F", $timestamp);
$newtable = "<table style=\"width: 225px; border-collapse: collapse;\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" bordercolor=\"#000000\">
<tr style=\"background:#68a1d5;color:#ffffff;\">
<td colspan=\"7\" style=\"text-align: center;\">
<span style=\"font-weight: bold;\"><a href=javascript:navigateCalendar($prev,$prevy)><img src=\"../images/previousmonth.gif\" alt=\"previous month\" style=\"border:none;\"></a>
<a href=javascript:navigateCalendar($currentmonth,$currentyear)><img src=\"../images/currentmonth.gif\" alt=\"current month\" style=\"border:none;\"></a>
$monthname $year <a href=javascript:navigateCalendar($next,$nexty)><img src=\"../images/nextmonth.gif\" alt=\"next month\" style=\"border:none;\"></a></span>";
echo $newtable;
//Now let's create the table with the proper month
?>
</td>
</tr>
<tr style="background: #0053a0;">
<td style="text-align: center; width: 15px;" onmouseover="this.style.background='#8bb3d9'" onmouseout="this.style.background='#0053a0'">
<span style="font-weight: bold;color:#ffffff;">Su</span>
</td>
<td style="text-align: center; width: 15px;" onmouseover="this.style.background='#8bb3d9'" onmouseout="this.style.background='#0053a0'">
<span style="font-weight: bold;color:#ffffff;">M</span>
</td>
<td style="text-align: center; width: 15px;" onmouseover="this.style.background='#8bb3d9'" onmouseout="this.style.background='#0053a0'">
<span style="font-weight: bold;color:#ffffff;">Tu</span>
</td>
<td style="text-align: center; width: 15px;" onmouseover="this.style.background='#8bb3d9'" onmouseout="this.style.background='#0053a0'">
<span style="font-weight: bold;color:#ffffff;">W</span>
</td>
<td style="text-align: center; width: 15px;" onmouseover="this.style.background='#8bb3d9'" onmouseout="this.style.background='#0053a0'">
<span style="font-weight: bold;color:#ffffff;">Th</span>
</td>
<td style="text-align: center; width: 15px;" onmouseover="this.style.background='#8bb3d9'" onmouseout="this.style.background='#0053a0'">
<span style="font-weight: bold;color:#ffffff;">F</span>
</td>
<td style="text-align: center; width: 15px;" onmouseover="this.style.background='#8bb3d9'" onmouseout="this.style.background='#0053a0'">
<span style="font-weight: bold;color:#ffffff;">Sa</span>
</td>
</tr>
<?php
$monthstart = date("w", $timestamp);
//if ($monthstart == 0){
//$monthstart = 7;
//}
$lastday = date("d", mktime (0, 0, 0, $month + 1, 0, $year));
$startdate = -$monthstart;
//Let's make 6 rows...
for ($k = 0; $k < 6; $k++){
?><tr><?php
//And 7 columns...
for ($i = 0; $i < 7; $i++){
$startdate++;
if (($startdate <= 0) || ($startdate > $lastday)){
//If we have a blank day in the calendar.
?><td style="background: #e0e0e0;"> </td><?php
} else {
if ($startdate == date("j") && $month == date("n") && $year == date("Y")){
?><td style="text-align: center; background: #68a1d5;" onmouseover="this.style.background='#d1d3d6'" onmouseout="this.style.background='#0053a0'"><?php
//Add in the database connector.
require_once ("dbconnector.php");
//Open the database.
$db = opendatabase();
$querydate = $year . "-" . $month . "-" . $startdate;
$myquery = "SELECT * FROM localEvents WHERE eventDateStart =" . $querydate;
$result = mysql_query($myquery);
$size = mysql_num_rows($result);
if (!$size) {
echo date ("j");
} else {
?><strong><?php echo date("j") ?></strong><?php
}
?></td><?php
} else {
?><td style="text-align: center; background: #A2BAFA;" onmouseover="this.style.background='#d1d3d6'" onmouseout="this.style.background='#A2BAFA'"><?php echo $startdate; ?></td><?php
}
}
}
?></tr><?php
}
?></table>
The problem portion of the code starts at line 103 and continues to line 110. Basically, if the date has any events at all it should bold the date - simple as that. It does display the date but doesn't change the font-weight.
This script is getting called as part of a AJAX app too if that is helpful any.