r00ttap Posted July 7, 2009 Share Posted July 7, 2009 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! Link to comment https://forums.phpfreaks.com/topic/165054-cant-seem-to-figure-this-calendar-function-out/ Share on other sites More sharing options...
r00ttap Posted July 8, 2009 Author Share Posted July 8, 2009 Anyone? Link to comment https://forums.phpfreaks.com/topic/165054-cant-seem-to-figure-this-calendar-function-out/#findComment-871307 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.