Jump to content

Can't seem to figure this calendar function out.


r00ttap

Recommended Posts

I have a calendar I'm using as a function that people can select dates from to post messages and also echo those same dates when they go back and edit a message. It seems everything works fine except for the first 9 days. From day 10 and on the dates will echo fine. I can't figure this one out. Here is the code for the first week of the calendar:

 

$today    = getdate();
$firstDay = getdate(mktime(0,0,0,$today['mon'],1,$today['year']));
$lastDay  = getdate(mktime(0,0,0,$today['mon']+1,0,$today['year']));

// Display the first calendar row with correct positioning
    echo '<tr>';
    for($i=1;$i<$firstDay['wday'];$i++){
        echo '<td class="calTd"></td>';
    }
   for($i=$firstDay['wday'];$i<=7;$i++){
        $actday++;
        if ($actday == $today['mday']) {
            $class = ' class="calActday"';
        } else {
            $class = ' class="calTd"';
        }
        $checked = "";
        $findDate = date("Y-m-$actday");
        $dateSelect = mysql_query("SELECT date FROM course_cancellations_dates WHERE id = '$_GET[id]'") or die(mysql_error());
        $cancelDates = array(); while($r=mysql_fetch_assoc($dateSelect)) { $cancelDates[] = $r['date']; }
        if(in_array($findDate, $cancelDates)) {
                $checked = "checked";
        }
        echo "<td$class>$actday<br><center><input type='checkbox' name='date[]' value='" // Continue on next line
        .date("Y-m-$actday"). "' $checked /></center></td>";
    }
    echo '</tr>';

 

I'm basically trying to gather the canceled dates and set them as an array and then if the dates are in that array, make the checkbox for those dates checked. This same code works for the rest of the month but for some reason not the first 9 days. Does anyone see anything wrong here?

 

Thanks for the help!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.