justinh Posted December 30, 2008 Share Posted December 30, 2008 Was wondering if someone could upload my calendar code, and help me figure out why may 2009 ( some other dates too ) are not displaying properly. <?php $date = time(); if(isset($_GET['direction'])){ switch($_GET['direction']){ case "up": $date = strtotime("+1 month", $_GET['date']); break; case "down": $date = strtotime("-1 month", $_GET['date']); } } $day = date('d', $date); $month = date('m', $date); $year = date('Y', $date); $firstday = mktime(0,0,0,$month, 1, $year); $title = date('F', $firstday); $dayofweek = date('D', $firstday); switch($dayofweek){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; } $dayinmonth = cal_days_in_month(0, $month, $year); echo "<a href=\"index.php?date=".$date."&direction=down\">< </a>$title - $year <a href=\"index.php?date=".$date."&direction=up\"> ></a>"; ?> <TABLE width="100%" bordercolordark="#000000" bordercolorlight="#FFFFFF" cellpadding="5"> <TBODY><TR><TH vAlign=center align=middle width="14%" bgcolor="#000000"><font size="1" color="#FFFFFF" face="Verdana"> Sunday</font></TH><TH vAlign=center align=middle width="14%" bgcolor="#000000"><font size="1" color="#FFFFFF" face="Verdana"> Monday</font></TH><TH vAlign=center align=middle width="14%" bgcolor=#000000><font size="1" color="#FFFFFF" face="Verdana"> Tuesday</font></TH><TH vAlign=center align=middle width="14%" bgcolor="#000000"><font size="1" color="#FFFFFF" face="Verdana"> Wednesday</font></TH><TH vAlign=center align=middle width="14%" bgcolor=#000000><font size="1" color="#FFFFFF" face="Verdana"> Thursday</font></TH><TH vAlign=center align=middle width="14%" bgcolor="#000000"><font size="1" color="#FFFFFF" face="Verdana"> Friday</font></TH><TH vAlign=center align=middle width="14%" bgcolor="#000000"><font size="1" color="#FFFFFF" face="Verdana"> Saturday</font></TH></TR> <?php $day_count = 1; echo "<tr>"; while ( $blank > 0 ) { echo "<td></td>"; $blank = $blank-1; $day_count++; } $daynum = 1; while($daynum <= $dayinmonth){ if($daynum == $day){ echo "<td><b>$daynum</td>"; $daynum++; $day_count++; }else{ echo "<td>$daynum</td>"; $daynum++; $day_count++; if($day_count > 7){ echo "</tr><tr>"; $day_count = 1; } } } while($day_count > 1 && $day_count <= 7){ echo "<td></td>"; $day_count++; } echo "</tr></table>"; ?> ty in advance Link to comment https://forums.phpfreaks.com/topic/138881-calendar-problem/ Share on other sites More sharing options...
justinh Posted December 30, 2008 Author Share Posted December 30, 2008 people hate calendars here at phpfreaks.com? lol.. seems like everytime i have a calendar question no one wants to answer it.. fixed the problem tho if($daynum == date('d') && $month == date('m')){ echo "<td><b>$daynum</b></td>"; $daynum++; $day_count++; Link to comment https://forums.phpfreaks.com/topic/138881-calendar-problem/#findComment-726225 Share on other sites More sharing options...
revraz Posted December 30, 2008 Share Posted December 30, 2008 Not really, it's more of when people post their entire code and want people to troubleshoot it with vague problem descriptions. Link to comment https://forums.phpfreaks.com/topic/138881-calendar-problem/#findComment-726251 Share on other sites More sharing options...
MatthewJ Posted December 30, 2008 Share Posted December 30, 2008 Well, and your posts are 13 minutes apart Not very patient are we? Link to comment https://forums.phpfreaks.com/topic/138881-calendar-problem/#findComment-726254 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.