aspekt9 Posted March 5, 2007 Share Posted March 5, 2007 I use a calendar script, Keith Deven's PHP Calendar. I've modified it to incorporate events into it and everything works great. The problem I'm having trouble with is when I print the year long calendar. For some reason it only reads the dates in the database for the current month, in this case March and it outputs the same days for every single month. I don't understand how I can fix this. The code displaying the year long calendar is: include 'calendarparent.php'; include 'config.php'; $today = date('j',$time); $month = date('n'); $year = date('Y'); $events = mysql_query("SELECT *, DATE_FORMAT(date, '%M %e, %Y %h:%m:%s') as date, DATE_FORMAT(date, '%c') as month, DATE_FORMAT(date, '%e') as day FROM calevents order by date desc") or die(mysql_error()); if($events) { $days = array(); while($row = mysql_fetch_array($events)) { if($row['month'] == $month) { $day = $row['day']; $days[$day] = array('events.php?action=view&id='.$row['id'], 'linked-day'); } } } echo "<table style=\"margin: auto\"width=450>"; echo "<tr>"; for($month=1; $month<=12; $month++) { echo "<td style=\"vertical-align: top\">"; echo parent_calendar($year, $month, $days,2); echo "<br /></td>"; if($month%3 == 0 and $month<12){ echo "</tr><tr>"; } } echo "</tr>"; echo "</table>"; I think the problem is: echo parent_calendar($year, $month, $days,2); Which makes sense because $days is retrieved from the database if it is equal to the current month, but how can I change this so each date prints to the correct month and day? Link to comment https://forums.phpfreaks.com/topic/41357-printing-full-year-calendar/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.